Jump to content

Mod Rewrite (example.com/contact.php to example.com/contact)


Recommended Posts

As the subject suggests, I would like to use Mod Rewrite to rewrite the url from example.com/contact.php to example.com/contact

 

I am currently learning how to use mod rewrite and read at least 10 tutorials but for some reasons I still can't create the rule. I simply need to remove the php trailer in all the files in the directory.

 

Here is the what I thought would work.

 

RewriteRule ^([a-z]+)$ /$1.php [L]

 

Below are other combinations I tried

 

RewriteRule ^([a-z]+)$ $1.php [L] (no slash before $1)

RewriteRule ^(.*)$ /$1.php [L]

...

 

I tried more combinations but really there is no point of writing them all.

 

Any ideas. Thanks in advance. By the way mod rewrite works on my server. I use it to rewrite www.example.com to example.com

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.