Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^(.*)host.com$
RewriteCond %{REQUEST_URI}!^/directory/
RewriteRule (.*) /directory/$1
everything is ok but if user enters this url - www.host.com/somedirectory (without ending slash) he is redirecting to www.host.com/directory/somedirectory/
Maybe sombody knows what is the reason.
Add a rule to fix missing slash in root directory only:
RewriteCond %{REQUEST_URI} !^/
RewriteRule .* / [R=301,L]RewriteCond %{REQUEST_URI} !^/directory/
RewriteCond %{HTTP_HOST} ^[^\.]\.host\.com
RewriteRule (.*) /directory/$1 [L]
The description of your code does not match what it does though. If you are trying to redirect from [xyz.domain.com...] to [domain.com...] then change the second ruleset to:
RewriteCond %{REQUEST_URI} !^/directory/
RewriteCond %{HTTP_HOST} ^([^\.])\.host\.com
RewriteRule (.*) /%1/$1 [L]
RewriteCond %{REQUEST_URI}!^/
RewriteRule .* / [R=301,L]
I think that in my case doesn't work.
Where can I find good .htacces tutorial?
Hmmmm... Well, you could also try:
RewriteCond %{REQUEST_URI} ^$
RewriteRule .* / [R=301,L]
Start here, and follow the links: Introduction to mod_rewrite [webmasterworld.com]
HTH,
Jim