Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.site\.net
RewriteCond %{HTTP_HOST} ([^.]+)\.site\.net [NC]
RewriteRule (.*) [site.net...] [P]
It works perfectly, but I have made subdomains in Cpanel too, so if I try to access them, I will get error 404 and url will be: site.net/hosting/site/subdomainsnameincpanel
So, how to create in rewrite thing, that it won't rewrite if url contains word, like "kirppari" (my subdomain)
Thank you a lot.
RewriteCond %{HTTP_HOST} !^www\.exmaple\.net
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.net [NC]
[i]RewriteCond %1 !^kirppari$[/i]
RewriteRule (.*) http://www.example.net/hosting/site/%1/$1 [P]
It is more usual to simply rewrite the incoming HTTP to a non-default location in the filesystem using an internal rewrite instead of a proxy through-put. This may not work with your 'cpanel-defined subdomains' but you should try to use it for the others:
RewriteCond %{HTTP_HOST} !^www\.exmaple\.net
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.net [NC]
RewriteCond %1 !^kirppari$
RewriteCond $1 !^hosting/site/[^/]+/
RewriteRule ^(.*)$ hosting/site/%1/$1 [L]