Welcome to WebmasterWorld Guest from 54.163.52.98

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Yet another Mod_ReWrite issue posting

     

pblancher

9:17 pm on Apr 27, 2006 (gmt 0)

5+ Year Member



Yes I too am posting about a mod-rewrite issue. the following is my .htaccess file. What is happening is that the variables are not getting passed to the appropriate pages unless they are the last two lines in .htaccess file.

How do I get it to allow the variable to be passed on the first four lines of rules?

TIA,

Phil

.htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^listings/([^/]+)/([^./]+)/?$ /listings.php?city_id=$1&listing_id=$2 [L]
RewriteRule ^listings/([^./]+)/?$ /listings.php?city_id=$1 [L]
RewriteRule ^lots/([^/]+)/([^./]+)/?$ /lots.php?city_id=$1&lot_id=$2 [L]
RewriteRule ^lots/([^./]+)/?$ /lots.php?city_id=$1 [L]
RewriteRule ^subdivisions/([^/]+)/([^./]+)/?$ /subs.php?city_id=$1&sub_id=$2 [L]
RewriteRule ^subdivisions/([^./]+)/?$ /subs.php?city_id=$1 [L]

JollyK

10:02 pm on Apr 27, 2006 (gmt 0)

10+ Year Member



Can you give an example of the URL (without your domain name of course) that is represented by the left-hand side of your rewrite?

I have absolutely no problems with something like this:

[what_ever.blah...]

Being turned into

[what_ever.blah...]

by using:

RewriteRule ^(.*)/(.*)/catid(.*) /script.cgi?STUFF=$1&THING=$2&CAT=$3 [L]

It looks like you may be trying to do a similar thing but are using ([^/]+) instead of (.*).

JK

pblancher

11:04 pm on Apr 27, 2006 (gmt 0)

5+ Year Member



example:

[site.com...]
[site.com...]

[site.com...]
[site.com...]

[site.com...]
[site.com...]

just seems that on the last one the city_id works, but the first two sets don't

JollyK

11:45 pm on Apr 27, 2006 (gmt 0)

10+ Year Member



RewriteRule ^lots/([^/]+)/([^./]+)/?$ /lots.php?city_id=$1&lot_id=$2 [L]

I do notice you have a . in the last one and not in the first one. ([^/]+) vs ([^./]+) . I believe that "." is "any character", so by leaving it out, you may be breaking your rule. You could also just try:

RewriteRule ^listings/(.*)/(.*)/?$ /listings.php?city_id=$1&listing_id=$2 [L]

I'm no mod_rewrite guru, but I think the above would work. Or maybe it's just the missing ".".

JK

pblancher

11:59 pm on Apr 27, 2006 (gmt 0)

5+ Year Member



its still making its error, even with changing it as you have.

when I go to /listings/city/number the page displays none of the $_GET variables so they are not getting passed as they should be. Same with /lots/city/number, but yet with subdivision/city/number they get passed.

in each file, listings.php, lots.php and subs.php I just have an echo statement to show each of the variables from the query string.

jdMorgan

5:22 pm on Apr 28, 2006 (gmt 0)

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



I don't see anything wrong with the original code, although as JollyK has pointed out, you don't need the "." in the grouped excluded characters.

Using a specific pattern like ([^/]+) is much more efficient than using (.*) when more than one sub-pattern is used. (See this post [webmasterworld.com] for details.)

Have you tried requesting any of the URLs that don't work, but with a trailing slash? Does that make any difference?

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month