当前位置: 动力学知识库 > 问答 > 编程问答 >

apache - .htaccess rewrite to convert forward slash (/) to dash (-)

问题描述:

I need a simple rule to rewrite

  • domainn.com/section/page

to

  • domain.com/section-page.html

网友答案:
RewriteRule ([^/]+)/([^/]+) $1-$2.html
网友答案:

try this rule:

RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteRule ^([^/]+)/([^/]+)/?$ /$1-$2.html [R,L]
网友答案:

RewriteEngine On

RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ $1-$2.html [QSA,L]

If you would like to forward your users so the URL shows the change, place R=301 before QSA. R = Redirect, 301 = Permanent.

分享给朋友:
您可能感兴趣的文章:
随机阅读: