Webmasters Stack Exchange is a question and answer site for pro webmasters. 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 have redhat linux server and i was using /var/www/html to display my site.

By using the following directive rewrite mod was working fine.

<IfModule mod_rewrite.c>
  # Enable mod_rewrite engine
  RewriteEngine on

  # WITH mandatory 'www.'
  #RewriteCond %{HTTP_HOST} ^$uri\.$tld$ [NC]
  #RewriteRule ^(.*)$ http://www.$domain$1 [L,R=301]

  # WITHOUT 'www.'
  RewriteCond %{HTTP_HOST} ^www\.$uri\.$tld$ [NC]
  RewriteRule ^(.*)$ http://$domain/$1 [L,R=301]

After the addition of

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domainmaster.com
ServerAlias domainmaster.com *.domainmaster.com
DocumentRoot /var/www/domainmaster

<VirtualHost *:80>
ServerName www.domainother.com
ServerAlias domainother.com *.domainother.com
DocumentRoot /var/www/domainother

url rewrite doesn't work. Website files wasn't modified. .htaccess file redirects all traffic to index.php and index.php decides which page to display.

Any ideas?

share|improve this question
What are $uri, $tld and $domain? These domains are presumably intended to be separate (different .htaccess files etc)? – w3dk Jan 23 '13 at 8:49
i think it's for multiple domains support.I just put this code and my site was working perfectly (as long as i didn't add the virtual hosts directives). Without (and my site was located to /var/www/html) <VirtualHost *:80> ServerName www.domainmaster.com ServerAlias domainmaster.com *.domainmaster.com DocumentRoot /var/www/domainmaster </VirtualHost> every call on domainmaster was returning user to root but index.php couldn't get the path (like the server redirected the user back to root (not the .htaccess file). With the addition all domains are like there is no mod_rewrite enabled for them! – dtakis Jan 23 '13 at 12:09

Where do you place the mod_rewrite directives that you have provided?

If you still have those directives in httpd.conf, then, perhaps, they fall outside of the VirtualHost directives, and have no effect on your vhost domains?

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.