I'm trying to do a Rewrite subdomains to subdirectories on htaccess. Searching here I did the rule below:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com\.br
RewriteCond %{REQUEST_URI} !^/sd_
RewriteRule ^(.*)$ http://domain.com.br/sd_%1/$1 [P,L,NC,QSA]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*)\.domain\.com\.br
RewriteCond %{REQUEST_URI} !^/sd_
RewriteRule ^(.*)$ http://domain.com.br/sd_%1/$1 [P,L,NC,QSA]
#Rewrite for my Framework
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
When I access the address: http://user.domain.com.br or the address: http://www.user.domain.com.br they're redirected without change the URL address to: http://www.domain.com.br/sd_user/
Well, fine. My problem is:
When someone access a adrees with haven't a folder, .htaccess redirect it to a specific folder. For example:
I haven't a folder called "sd_joecompany", then I want to redirect it to a default folder named "sd_system". If I access http://joecompany.domain.com.br/ and not exists the respective folder, this address may point to "sd_system" keeping the address.
With this code, when I access a subdomain without a respective folder, the following error appear:
Proxy Error
The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /index.php.
Reason: Max-Forwards has reached zero - proxy loop?
I'm not sure about the clarity of my doubt, and I'm sorry for my poor english.
I know a little about .htaccess and these rules. Everithing on the code above, I gathered here!
Thank you since now!