Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|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
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

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.