Jé Queue
Jé Queue

Reputation: 10637

How to mod_rewrite for HTTP_HOST?

I am working in a shared account on a hosting provider with several domain names. Goal is to have each domain name have their own virtual directories. In my personal configured htdocs/ directory, I have a subdirectory set up for each domain name, something quite similar to this:

htdocs/
    foo.com/
        index.html
    bar.com/
        test.txt

I'd like to serve http://foo.com/index.html instead of http://foo.com/foo.com/index.html.

Is this the proper way to set up .htaccess in htdocs/?

RewriteEngine on
RewriteCond %{HTTP_HOST} .*foo\.com [NC]
RewriteRule ^/(.*)$ /foo.com/$1 [L]

I assume no as this does not appear to be working and I'm not granted access to error logs. What is the proper syntax?

Upvotes: 0

Views: 780

Answers (1)

jaywon
jaywon

Reputation: 8234

You shouldn't have to set up .htaccess rules for different domains like that if your on a shared account. Most hosting providers allow you the capability to set up add-on domains, which sets up the proper mappings for you.

Upvotes: 1

Related Questions