Forum Moderators: phranque

Message Too Old, No Replies

Some noob questions about pretty URLs.

         

Dragosh

12:10 pm on Oct 17, 2007 (gmt 0)

10+ Year Member



Hi. I have searched many sites for giving me some code for real pretty urls but i could only find things i already knew. I have found how to rewrite the urls with apache mod_rewrite,but mod_rewrite is not what i want. I want to have pretty url not just links on the page,but also in the adress bar of the browser. With mod rewrite i can just redirect some kind of urls but in the adress bar it gives me the real,ugly url. Why i want that? Because when people stumble upon my page they will stumble upon the adress in the adress bar of the browser and that's the ugly one. That ugly url is then indexed by google but for example site.com/index.php?number=x?category=y is not the same as site.com/x/y/ . Many forum engines use this method.

Please give me references or show me how to do that.

Thanks in advance!

jdMorgan

4:56 pm on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This thread [webmasterworld.com] describes the three-step process, including changing the links on your pages and mod_rewrite code, to implement search-engine-friendly URLs.

The links on your pages define the URLs, so you must change your pages -- PHP preg_replace often comes in handy for this, and some shopping carts and CMS systems may have 'plugins' available to do this for you.

Once the URLs are changed, mod_rewrite is used to recognize requests for the new URLs, and 'map' them to your script so that the requested page can be generated correctly.

In a third (optional) step, you can redirect direct client requests for the old ugly URLs back to the new pretty versions. This takes care of previously-bookmarked and linked URLs, and speeds up search engine replacement of your old ugly URLs with the new pretty ones.

Jim

Dragosh

6:24 pm on Oct 17, 2007 (gmt 0)

10+ Year Member



Thank you a lot! I didnt think that was done with php,only thought it was a matter of apache mods,but heh ... i was wrong.

g1smd

6:49 pm on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There is much confusion about redirects and rewrites.

A rewrite takes a request for a URL and maps that request to an internal server filepath, without revealing what that path actually is.

A redirect takes a request for a URL and tells the browser to request a new and different URL, additionally returning a 301 or 302 status.