Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite - Turning query strings into friendly URLs

How to turn nasty query strings into friendly URLS

         

Ben_Johnson

9:14 am on Apr 20, 2006 (gmt 0)

10+ Year Member



I need some help setting up my .htaccess file.

I basicaly want to turn my nast query strings into friendly URLS.

Here is exactly what I want to do. Turn this:

www.somedomain.com/?controller=controller_name&controller_action=some_action

to

www.somedomain.com/controller_name/some_action

Currently the first URL works fine. I just need to know waht to put in my .htaccess file to make the second URL work.

Thanks a lot for your help and time.

freewebsiteideas

5:44 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



Try this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule //(.*)/(.*)/(.*)/(.*)/$ /?$1=$2&$3=$4

seminole

9:15 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



Hello,

I was looking at some of the mod rewrites for this same need. Wouldn't you be better off by putting a ".html" at the end. Doesn't static html links help get a better rank, or not?

I was under the impression that a URL like this rewrite with no suffix, the SE knows is some kind of dynamic stuff with a mod rewrite. It is more SE friendly to go ahead and give it a ".html" at the end?

Am I right or wrong, any other opinion on that..

thanks, seminole

jdMorgan

12:29 am on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ben,

I've been meaning to address this frequently-asked question, so here [webmasterworld.com]'s a write-up.

Jim

Ben_Johnson

3:28 am on Apr 21, 2006 (gmt 0)

10+ Year Member



Nice post Jim. I am reading through it. Hopefully I can get this to work.

Thanks a lot.

maximillianos

12:02 pm on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sold on the idea of moving to a "mod_rewrite" model. Particularly in the case where folks just want to change from having all their variables in the URL to having them look like folders in the URL. Search engines are very well aware of these tactics, and I don't think they will be considered as important down the road.

Think about it. If you were Google, and you knew that there was a pretty easy way for folks to modify their URLs to look like standard HTML folders and files (static), wouldn't you start putting LESS importance on such things in your ranking? I would, because it no longer means anything.

My site has been using parameters in the URL (&x=2&y=2&z=4, etc) for over 6 years now. I've never noticed any difference in ranking of my pages versus some competitor pages that use the mod_rewrite technique.

Now I do see other benefits to using a mod_rewrite URL, for instance it helps cloak some of your logic by hiding which parameters are dynamic versus static, etc. This can help reduce the number of folks hacking away at your content, etc. There is also the visual appeal. The nice, clean, modular URL is more gentle on the eyes.

If you already have an established site, I wouldn't bother making the big leap and converting all your URLs. If you are a new site starting out, you have nothing to lose and it may be a good design to include.

Just my 2 cents.