View Full Version : .htaccess rewrite url

07-18-2007, 04:14 PM
Hello. I have a quick question regarding url rewriting. I've been successful at using regular expressions in the past, but this one (though simple) has me stumped.

I'd like to make links throughout the site look like this:


However, the php file is actually located at:


Thus, a simple redirect is in order, but I'm unable to get the syntax correct. Here is what I currently have:

RewriteRule ^([A-Za-z]+)?$ /pages/$1.php

And the .htaccess file is located in the pages directory.

Can anyone provide assistance?



07-18-2007, 07:40 PM
I'm thinking you need to store the .htaccess file in your base directory, but I'm no expert at mod rewrite.

07-19-2007, 03:26 AM
Thanks, that fixed the problem. But now I've got another url rewrite problem. After supplementing the last code, I attempted to do this on another page: www.rndpig.com. In this case, I can type www.rndpig.com/about into the address bar and it will take me to the correct page. The actual page address is www.rndpig.com/pages/about.php. However, when I changed links on the site to www.rndpig.com/about the links failed.

What could be causing the difference in typing the address into the address bar and clicking on a link that goes to the same address?

Any help would be appreciated.