开发者

RewriteRule that will force a trailing slash

开发者 https://www.devze.com 2023-04-08 15:40 出处:网络
Currently I have a folder [contact-us] mydomain.com/conta开发者_运维百科ct-us/ Im planning to remove this folder and will just add a contact-us.php

Currently I have a folder [contact-us]

mydomain.com/conta开发者_运维百科ct-us/

Im planning to remove this folder and will just add a contact-us.php

mydomain.com/contact-us.php

How can I create a RewriteRule that will map

mydomain.com/contact-us/ -> mydomain.com/contact-us.php

(Note I want to force a trailing slash)


Use:

RewriteEngine On
RewriteRule ^contact-us$ http://domain.com/contact-us/ [R,L]
RewriteRule ^contact-us/?$ /contact-us.php [NC,QSA,L]

This way is someone type: contact-us or contact-us/ it will go to your contact-us.php


RewriteRule ^contact_us/$ /contact_us.php [QSA]

I can't remember if you need a / at the start, so if this doesn't work try ^/contact_us/$

0

精彩评论

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