0

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!!

3 Answers 3

3

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.

1

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.

0

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.

1
  • Hey thank you very much for the advice. Finally getting to grips with mod_rewite!
    – drs
    Dec 6, 2009 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.