Variables in RewriteRule

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Variables in RewriteRule

Post by alex.barylski »

I have declared a environment variable in my .htaccess something like:

Code: Select all

SetEnv default_arg "jump"
 
RewriteEngine on
RewriteRule ^([a-z0-9\-]+)\.php$ index.php?{%default_arg%}=$1 [QSA]
Is something like this possible?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Variables in RewriteRule

Post by VladSun »

Something like that?

http://httpd.apache.org/docs/1.3/mod/mo ... ewriteCond
http://httpd.apache.org/docs/2.0/mod/mo ... ewriteCond
There is the special format: %{ENV:variable} where variable can be any environment variable. This is looked-up via internal Apache structures and (if not found there) via getenv() from the Apache server process.
And ... what's the main idea of doing this?
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Variables in RewriteRule

Post by alex.barylski »

Just experimenting right now... :)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Variables in RewriteRule

Post by alex.barylski »

Just experimenting right now... :)

Edit | Thanks again BTW
Post Reply