开发者

Forcing a trailing slash at the end of the URL

I currently have this on my htaccess file to map mydomain.com/contact-us -> mydomain.com/con开发者_开发知识库tact-us.php

RewriteEngine On
RewriteRule ^contact-us(\/?)$ /contact-us.php [NC,QSA,L]

My problem is I want it ALWAYS to show a / at the end of the URL even if the users did not typed it, currently both with or without slash it will map to mydomain.com/contact-us.php


You could redirect requests to the page without a slash to the page with a slash with a permanent redirect:

RewriteEngine On
RewriteRule ^contact-us$ /contact-us/ [R=301,QSA,L]
RewriteRule ^contact-us/$ /contact-us.php [NC,QSA,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜