Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wanting to create redirect for urls using .htaccess

to map to my existing folder structure what is like

two variable the subdomain which can differ and the showtitle

so i wrote

RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$
RewriteCond %{REQUEST_URI} ^/([a-z]*)/sitemap.xml
RewriteRule ^(.*)$$1_3day.xml [L]

which redirects to

Do i need to combine both RewriteCond into one to access both variables? Or can I get the variables from as they are?

share|improve this question
Where's this .htaccess file located? And what request is it handling? It doesn't add up for the $1 to be an empty string. – Shane Madden Jul 29 '12 at 18:56
the .htaccess is located in the root directory, i'm just passing the example url through – bertsisterwanda Jul 30 '12 at 8:02
up vote 1 down vote accepted

Managed to get it working this way.

RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$
RewriteRule ^([a-z]*)/sitemap.xml$1_3day.xml [L,R=302]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.