Need some quick help

Discuss practical ways rearrange URLs using mod_rewrite.

Need some quick help

Postby ladrao2007 » Wed Aug 20, 2008 8:12 pm

I am in need of some help. I have a site that has a directory of stores listed throughout my state and soon to be nationally.

Right now my url looks like:
http://www.mydomainname.com/city-search.php?city=Reno

and also

http://www.mydomainname.com/state-searc ... ate=Nevada

I would like to get the URLs to look nicer and friendly. Here is what I would like them to look like

http://www.mydomainname.com/city/Reno

and

http://www.mydomainname.com/state/Nevada

if anyone has some info on how to go about doing this, I think I have tried just about every example I can find, hence why I resort to having to ask a pro.

Thanks in advance

*I have been playing around with it and i can get it to work as http://www.mydomainname.com/Reno by using


Code: Select all
Options +FollowSymLinks +MultiViews
RewriteEngine On

# Don't match existing files.
RewriteCond %{SCRIPT_FILENAME} !-f
# Don't match existing directories.
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /city-search.php?city=$1 [QSA,L]


but if I change the RewriteRule to
Code: Select all
RewriteRule ^city/([^/]+)/?$ /city-search.php?city=$1 [QSA,L]

then it loses all the css elements of the page.. Any ideas?
ladrao2007
 
Posts: 2
Joined: Wed Aug 20, 2008 8:04 pm

Postby richardk » Sat Aug 23, 2008 9:53 am

FAQ: Relative paths to images, JavaScript, CSS and other external/linked files are broken.

And
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^city/([^/]+)/?$  /city-search.php?city=$1   [QSA,L]
RewriteRule ^state/([^/]+)/?$ /state-search.php?state=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 6 guests

cron