.htaccess - Use variable in RewriteCond match -


i'm running site in 2 environments: production , development.

each server has vhosts.conf file, sets environment variables. 1 of these variables correct subdomain use.

vhosts.conf (development server)

rewriterule .* - [e=dev_or_www:dev] 

vhosts.conf (production server)

rewriterule .* - [e=dev_or_www:www] 

i have .htaccess file, identical on both servers. trying rewrite old domain urls new ones, while preserving subdomain, this:

.htaccess

rewritecond "%{http_host}" "%{env:dev_or_www}\.olddomain\.com" [nc] rewriterule "^/(.*)"  "http://%{env:dev_or_www}.newdomain.com/$1" [l,r=301] 

but rewritecond above not work. %{env:dev_or_www} not matching www or dev, , rule not applied. how can use variable match http_host against?

if need more details, or if question unclear, ask.

you can use following :

rewritecond %{env:dev_or_www} ^(.+)$ rewritecond %1.olddomain.com ^(www|dev)\.olddomain\.com$ [nc] rewriterule /(.*) http://%1.newdomain/$1 [l,r=301] 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -