[E=REQUEST_URI] makes REDIRECT_REDIRECT_REQUEST_URI ?? help!

Oh, the strange things mod_rewrite does!

[E=REQUEST_URI] makes REDIRECT_REDIRECT_REQUEST_URI ?? help!

Postby jonthepirate » Wed Jan 14, 2009 4:19 pm

I want to internally rewrite one request to another and modify the REQUEST_URI. The problem is that in my rewritten request, the REQUEST_URI php sees is still the original one. I see that there is a SERVER['REDIRECT_REDIRECT_REQUEST_URI'] that gets created with the code I've pasted below. How can I formulate a rewrite rule that properly *changes* the request_uri value?

RewriteRule .* /a/b/c/ [E=REQUEST_URI:/a/b/c/]

<?php
echo $_SERVER['REQUEST_URI'];
?>

What am I doing wrong?

Thank you!!!
Jon
jonthepirate
 
Posts: 1
Joined: Wed Jan 14, 2009 4:11 pm

Postby richardk » Thu Jan 15, 2009 3:27 am

Do you have any other rules?

In .htaccess files (i am not sure about other places like <VirtualHost>s) all environmental variables you create are prefixed with REDIRECT_. This is either a "security" feature so you don't change things that will break Apache's processing or because a sub-request is made for the new URL. Or possible both.

The best you can hope for is REDIRECT_REQUEST_URI. You should be able to achieve that with
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_REQUEST_URI} ^$
RewriteRule .* /a/b/c/ [E=REQUEST_URI:/a/b/c/,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 15 guests

cron