Forum Moderators: phranque
www.domain.com to www.domain.com/mydir/
I have the following in my custom settings
RewriteEngine On
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^/$ /mydir/ [R]
But the problem is only if someone types
domain.com it goes to that mydir other wise not.
Please help me in this regard
Again My requirement is
[domain.com...] -> [comain.com...]
domain.com -> [comain.com...]
www.domain.com -> [comain.com...]
[domain.com...] [comain.com...]
Welcome to WebmasterWorld!
The "http://" part is required to specify the protocol used to connect to your server; It is not formally part of the URL visible to RewriteRule. So, your problem reduces to:
domain.com -> http://www.domain.com/mydir/
www.domain.com -> http://www.domain.com/mydir/
The only added complication is that steps must be taken to prevent an infinite redirection loop.
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^/(.*) http://www.domain.com/$1 [R=301,L]
#
RewriteCond %{REQUEST_URI} !^/mydir/
RewriteRule ^/(.*) /mydir/$1 [L]
I have further assumed that this code goes into httpd.conf, rather than .htaccess.
For more information, see the references cited in our forum charter [webmasterworld.com].
Jim