3

Currently I have a folder [contact-us]

mydomain.com/contact-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)

Book Of Zeus
  • 49,509
  • 18
  • 174
  • 171
Paul Sanchez
  • 2,391
  • 2
  • 15
  • 9

2 Answers2

4

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

Book Of Zeus
  • 49,509
  • 18
  • 174
  • 171
  • It works but it doesnt add / at the end of the URL I want it to automatically add / at the end `mydomain.com/contact-us` <- no / at the end – Paul Sanchez Sep 24 '11 at 22:54
0
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/$

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592