The following rewrite redirects http://example.com/ to http://example.com/www/www.example.com/public%5Fhtml instead of http://www.example.com/. /www/www.example.com/public_html is the DocumentRoot.

# Rewrite Rules for Example
RewriteEngine On
RewriteBase /

# Redirect from example.com to www.example.com
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

This redirect is in a VirtualHost *:80 with the settings:

ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@example.com

Options +FollowSymLinks
DocumentRoot /www/www.example.com/public_html

and the rewrite is inside <Directory />

Any ideas why it would do this? I looked into the Apache manual and it says that using ${HTTP_HOST} in your RewriteCond will add the host to the RewriteRule instead of just the URL-Path. Well this is a VERY common rewrite, and I've never seen this happen before.

link|improve this question

is there any way to say: add some extra words to a url using mod_rewrite? Example: change: detail.php?id=$2 to: pressure-valve (normal mod_rewrite url) to: search-friendly-intro-to-pressure-valve This would append to all urls in a certain section of a site , like product pages. POSSIBLE?? Please send answer to my email. THANKS ! – user69143 Feb 2 '11 at 0:38
feedback

1 Answer

up vote 0 down vote accepted

The problem was <Directory />. Once I updated it to <Directory /www/www.example.com/public_html> it worked just fine.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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