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

时间秒杀一切 提交于 2019-12-24 23:51:59

问题


I need a simple rule to rewrite

  • domainn.com/section/page

to

  • domain.com/section-page.html

回答1:


RewriteRule ([^/]+)/([^/]+) $1-$2.html



回答2:


try this rule:

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



回答3:


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.



来源:https://stackoverflow.com/questions/5720844/htaccess-rewrite-to-convert-forward-slash-to-dash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!