drs
drs

Reputation: 1265

mod_rewrite and hyperlinks

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

Upvotes: 0

Views: 171

Answers (3)

Ben
Ben

Reputation: 11208

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.

Upvotes: 0

Amber
Amber

Reputation: 527173

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.

Upvotes: 1

Ben James
Ben James

Reputation: 125227

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.

Upvotes: 3

Related Questions