Question

what I am trying to do is to use SetEnv for a dynamic URL. In example for index.php I do this

<IfModule somemodule.c>
<Files index.php>
    SetEnv somevariable
</Files>
</IfModule>

However If I wanted to do this for index.php?something=123 then what should I put in my .htaccess? Will it work with SetEnvIf request_URI somehow cause I couldn't get it to work. Another thing I think could be the solution is to use rewrite_mod but I have no idea how to do it. Thanks in advance for any help!

Was it helpful?

Solution

You can use mod_rewrite's E flag to set environment variables:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^something=123$
RewriteRule ^index\.php$ - [L,E=somevariable]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top