I'll pay $20 for MOD REWRITE help

Status
Not open for further replies.

barman

New member
Aug 14, 2006
6,507
156
0
Internets
This could be the quickest $20 if i can get this shit to work.

I've spent too much time trying so I'm fucking done with it..


I have a Wordpress site and this is your standard rewrite rule for WP

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


The work I need is as follows...

Below are examples of the query string in the URLs I have...

http://www.mysite.com/sell.php
(lists all of the states)

http://www.mysite.com/sell.php?state=CO
(lists all of the cities in the state)

http://www.mysite.com/sell.php?state=IA&city=Dubuque
(final LP with the state and city variables passed)

I need the URLs to read

http://www.mysite.com/sell < - root url
http://www.mysite.com/sell/ST
http://www.mysite.com/sell/ST/City
where ST = State (abbreviations) and City is the city of course.



This is as far as I got

#RewriteEngine On
#RewriteBase /
#RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_]+)$ sell.php?state=$1&city=$2 [L]


I can't get it to work... and I don't know why (whether it conflicting with the other WP shit or what)
 


RewriteRule ^sell$ sell.php [L]
RewriteRule ^sell/([^/]+)$ sell.php?state=$1 [L]
RewriteRule ^sell/([^/]+)/([^/]+)$ sell.php?state=$1&city=$2 [L]

didn't test it but should work
 
Last edited:
that was nice of you @chucklefuck...I am going to rep you just cause I know what it's like to need some programming help big time! nice and generous...
 
Hate to be a buzzkill but I'm having a problem just like that. I hate this shit. After you do the mod rewrite your still going to have access to the old URL.

If someone types
http://www.mysite.com/sell.php?state=IA&city=Dubuque

They can still access that page the same as
http://www.mysite.com/sell/ST/City

So that starts creating duplicate content with the SE. If it hasn't been indexed yet, good, but if it has you'll need a redirect.

You can try something like this in addition to what chucklefuck gave you

RewriteRule ^/?sell\.php?state=([^/]+)&city=([^/]+) /sell/$1/$2 [R=301,NC,L]

I have no idea if that will work because I'm having the biggest pain in the ass time trying to figure this out too. Just thought I'd point that out though.
 
I am having shitty luck with computers. I just wrote a fucking post and my comp went crazy and it didn't go through!

Anyway, what I wrote before was you mite have to add a redirect to your old urls to prevent duplicate content with the SE. With the rewrite you just provide an alternative path to that content, meaning you can still access it with the old url as well as the new.

Try something like this if your pages are already indexed:

RewriteRule ^/?sell.php?state=([^/]+)&city=([^/]+)$ /sell/$1/$2 [R=301,NC,L]

I don't know if that will work but it's worth I try, I'm having a pain in the ass time with this mod rewrite stuff too. It makes no sense.
 
Status
Not open for further replies.