Forum Moderators: phranque

Message Too Old, No Replies

Using ENV variables and mod rewrite

         

creaturecorp

11:19 pm on Apr 19, 2006 (gmt 0)

10+ Year Member



Hello,

I have a setup like [mydomain.com...]

RewriteCond %{REQUEST_URI} /user/([^.]+)/ [NC]
RewriteRule .* - [E=userID:%1]

this doesn't seem to be working. Any tips? Essentially I need the username (in this case, "blah") to be in a variable.

Thanks in advance,

~Creaturecorp

jdMorgan

11:36 pm on Apr 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your syntax is essentially correct, although a separate RewriteCond is not needed. But I have heard of 'strange' problems while setting envars like this, where it doesn't work (the variable is not immediately available) unless you do certain other things at the same time. Try the following variation:

RewriteRule ^user/([^/]+)/ - [NC,E=userID:$1]

If that doesn't work, look to the code that is de-referencing the variable, as the problem may lie there. Also, be aware that the variable will only be available to modules and content-handlers that run *after* mod_rewrite runs. If using Apache 1.x, there's a chance that your LoadModule list is mis-ordered; Modules loaded last run first, as documented in the Apache 1.x manual.

If this code is for use in httpd.conf or conf.d rather than .htaccess, then precede the 'user/' pattern with a slash.

Jim

creaturecorp

12:25 am on Apr 20, 2006 (gmt 0)

10+ Year Member



Ahh, that's essentially what I had at one point but without the NC.

Thank you very much! :)