homepage Welcome to WebmasterWorld Guest from 54.226.180.223
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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

Apache Web Server Forum

    
Yet another Mod_ReWrite issue posting
pblancher




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

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




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

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




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

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




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

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




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

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




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

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

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