This rewrite rule is inside <directory> -section in httpd.conf:
- Code: Select all
# mod_dir fix
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+\.)([^\.]+\.[^\.]+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sub/%2%3%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/sub/%3%{REQUEST_URI}/ -d
RewriteCond %{SERVER_PORT} !^443$
RewriteRule [^/]$ http://%1%2%3%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+\.)([^\.]+\.[^\.]+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sub/%2%3%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/sub/%3%{REQUEST_URI}/ -d
RewriteCond %{SERVER_PORT} !^80$
RewriteRule [^/]$ https://%1%2%3%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sub/%2/ -d
RewriteRule !^sub(/.*)?$ /sub/%2%{REQUEST_URI} [QSA,L]
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+\.[^\.]+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sub/%2/ -d
RewriteRule !^sub(/.*)?$ /sub/%2%{REQUEST_URI} [QSA,L]
E.g. I'll go to:
http://a.a.a.a.domain.com/sub/mydom.net/
If /htdocs/sub/mydom.net/ exists --> above address will lead to mydom.net site(/htdocs/sub/mydom.net/) which is wrong.
This address should show 404 mostly because there is no /sub/mydom.net/ dir inside the /htdocs/sub/a.domain.com/
E.g. this address:
http://a.a.a.a.domain.com/sub/
It does not check/goto "sub" dir
inside the /htdocs/sub/a.domain.com/
It will lead to /htdocs/sub/ or
http://domain.com/sub/ which is wrong.
Original address typed will stay in the address bar always, which is correct.
Everything works except when going to:
http://asd.domain.com/sub, then it will map sub incorrectly.
?
(this rule seems not to work in htaccess inside htdocs, in httpd.conf it will, which is fine and preferable too)