3

The following rewrite redirects http://example.com/ to http://example.com/www/www.example.com/public_html 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 [email protected]

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.

0

1 Answer 1

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .