Empty variable when querystring present

Discuss practical ways rearrange URLs using mod_rewrite.

Empty variable when querystring present

Postby StijnVanDerRee » Thu May 21, 2009 6:55 am

Hi,

I've got the following rule to rewrite url's like "/docs/blah.324.html":

RewriteRule ^docs/(.*)$ /page.php?uri=docs&uri_docs=$1 [L]

This works, however when a querystring is appended to the url (e.g. "/docs/blah.324.html?ref=foo") the "uri_docs" variable is empty.

Anybody knowns why?

Thanks,
Stijn
StijnVanDerRee
 
Posts: 4
Joined: Thu May 21, 2009 5:13 am

Postby richardk » Thu May 21, 2009 7:06 am

Do you have any other rules?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby StijnVanDerRee » Thu May 21, 2009 7:12 am

Yes, a couple of more like that. Should I post them?

The rule seems to work, because it does arrive at page.php with "uri" set to "docs".
StijnVanDerRee
 
Posts: 4
Joined: Thu May 21, 2009 5:13 am

Postby richardk » Thu May 21, 2009 3:58 pm

Post them.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby StijnVanDerRee » Thu May 21, 2009 11:30 pm

Code: Select all
# rewrite rules
RewriteEngine on

# loginlink: /login/url
RewriteRule ^login/url/(.*)/?$ /loginlink/url/$1 [L]

# loginlink partners: /partners/login/url
RewriteRule ^partners/login/url/(.*)/?$ /partners/loginlink/url/$1 [L]

# documentatie
RewriteRule ^docs/(.*)$ /page.php?uri=docs&uri_docs=$1 [L]

# response
RewriteRule ^response/doorgaan/(.*)/?$ /page.php?uri=response/doorgaan&uri_response=$1 [L]
RewriteRule ^response/stoppen/(.*)/?$ /page.php?uri=response/stoppen&uri_response=$1 [L]

# alle 404's naar naar page.php
RewriteCond %{REQUEST_URI} !^/page\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ /page.php?uri=$1 [L]

Thanks for looking into this.
StijnVanDerRee
 
Posts: 4
Joined: Thu May 21, 2009 5:13 am

Postby richardk » Fri May 22, 2009 7:58 am

Try replacing
Code: Select all
RewriteCond %{REQUEST_URI} !^/page\.php$

with
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby StijnVanDerRee » Fri May 22, 2009 10:13 am

When checking the php that handles the request I saw the problem was there, and not with mod_rewrite. Sorry about that.
StijnVanDerRee
 
Posts: 4
Joined: Thu May 21, 2009 5:13 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 27 guests

cron