views:

47

answers:

3

Hi Guys,

I'm trying to get my head around mod_rewrite and friendly URLS.

OK, on a very basic level I have the following rule:

RewriteRule ^register$ register.php [L]

This allows me to browse to www.mydomain.com/register

The hyperlink within my pages shows register.php. Do I have to manually change my links to register?

Esentiallly, I do not want the .php extension on any of my links.

Thanks!!

+2  A: 

Yes, you must manually change the hyperlinks (or use your favourite search-and-replace tool). mod_rewrite can't do this for you; it can only rewrite incoming requests, not outgoing HTML.

Ben James
+1  A: 

Yes, you'll need to change the URL in your code if that's not what you want to show up in the address bar.

Amber
A: 

Just an addition:

Note that RewriteRule ^(.*)$ /$1.php rewrites all files for you which saves you typing a lot of rules ;) Offcourse you can add more validation to it by using something like RewriteRule ^(.*)$ /index.php?pageId=$1.

Ben Fransen
Hey thank you very much for the advice. Finally getting to grips with mod_rewite!
drs