homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Mod_rewrite questions from a noob!

10+ Year Member

Msg#: 4326 posted 8:41 pm on Aug 10, 2005 (gmt 0)

Hi guys, I am completely new to mod rewrite, and through reading I have "some" idea of what I am doing, but I figure it is easier to just ask my questions here and learn from the code.

I have url's of varying length like this http://mydomain.com/?keyword=new%20york%20car%20accident%20attorney&level=1

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

I used the above with some success, but what I really want to do it replace the %20 with a - and clean up the rest. Probably pretty simple.

The next part i'm more confused on is how I modify my php code in my source to use these new url's by default when the menu is built and such. Any help there would be huge as well.

Thanks in advance guys. I'm still trying to learn all this regex stuff.



WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4326 posted 1:40 am on Aug 11, 2005 (gmt 0)


Welcome to WebmasterWorld!

This search [google.com] should turn up some good threads to get you started with rewriting static to dynamic URLs.

Modifications of code in these threads [google.com] may help you in getting rid of hex-encoded spaces (the regex to match a space in a RewriteRule is "\ " -- that is, backslash space.)



10+ Year Member

Msg#: 4326 posted 11:53 pm on Aug 11, 2005 (gmt 0)

Thank you for the links, those helped a bunch. I ended up rewriting my code to replace the spaces with - to being with, then used some mod rewrite to get rid of the variables I didn't want. Finally I then modified the code for our menu system and such to spit out code without the variables as well (? = etc). Works perfectly and the url's are just how they should be.

thanks again.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved