Forum Moderators: phranque
I've for a long time been trying to make my .htaccess to fit my needs, but seems unfortunately impossible.
I want it to:
What I've come up with is:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com
RewriteRule ^(.*) http://example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com
RewriteCond $1!^www/
RewriteRule ^(.*) www/$1 [L]
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.example\.com(:80)?<>/([^/]*) [NC]
RewriteCond %1<>%3!^(.*)<>\1$ [NC]
RewriteRule ^(.*) /%1/$1 [L]
But that doesn't work exactly as I want, because:
I've been reading a lot in the documentation, but still can't get it working. Please help me.
Thanks in advance.
Regards,
wanze
If the folder named "hello" doesn't exist, when I go to [sub.example.com...] (without trailing slash), it externally redirects me to [sub.example.com...] and gives me an the error it's supposed to. - I don't want it to redirect me.
Add a RewriteCond based on the -d flag and {REQUEST_FILENAME}, or add a rule to add a trailing slash to all requests which do not contain a filetype in the last URL-path element.
http://hello.hello.example.com/ (2 subdomains) shows me the /, which should not be able to be shown, because of my redirects. - I want it to show me /hello.hello/.
You RewriteCond is designed to "find" the end of the subdomain based upon the "." (full stop) character. You won't be able to handle multiple subdomain levels using that method.
If I go to [hello.example.com...] it takes the content from /hello/. - I want it to try to access /hello/hello/.
This is not possible without exposing your server to the liklihood of a redirection deadloop.
When I go to [example.com...] it takes the content from /hello/ (or what also is [example.com...] - I want it to take the content from /hello/ and not /www/hello/.
Sorry, this is not clear. I don't see any reason in your code that this would happen.
Jim
Add a RewriteCond based on the -d flag and {REQUEST_FILENAME}, or add a rule to add a trailing slash to all requests which do not contain a filetype in the last URL-path element.
Could you give me an example?
This is not possible without exposing your server to the liklihood of a redirection deadloop.
Now I don't know what I don't understand. Either it's the code, or your English, Because I seriously don't understand anything(I'm from Denmark). :)