Answer the question
In order to leave comments, you need to log in
.htaccess setup, dynamic third level domains?
Good day to all.
Such a situation:
there is a 2nd level domain mysite.com
all 3rd level domains *.mysite.com are sent to one .htaccess
1) it is necessary that all 3rd level domains be passed as a parameter without changing the string for the user, then there
domain1.mysite.com was passed as www.mysite.com/?domainname=domain1, but the user saw domain1.mysite.com
2) all other parameters should remain and pass unchanged domain1.mysite.com/?param=123 -> www.mysite.com/?domainname=domain1&m=123
3) so that all 3rd level domains physically refer to a certain "alldomains" folder as a home directory (for all domains, one folder, except for the "www" domain) the "alldomains" folder can be in the home directory of the general site mysite. com, may be one level higher, for example, it doesn't matter.
4) subdirectories should work for third-level domains, that is, domain1.mysite.com/somedir/?param=123 -> www.mysite.com/somedir/?domainname=domain1&m=123 (directory "somedir" physically lies in "alldomains "), and www.mysite.com/somedir/?param=123 ->
www.mysite.com/somedir/?param=123 then when requesting this folder through the common domain www.mysite.com, a 404 error should be issued.
6) the www.mysite.com domain should work from the general directory of the mysite.com site
7) the mysite.com domain should be redirected to www.mysite.com with the site name replaced in the browser line.
I rummaged through the entire Internet, here's what happened:
1, 2, 6, 7 points work
with 4, I understand that I need to use {REQUEST_URI}, but something "my paws hurt, then the tail falls off." One starts working, the other stops.
.htaccess:
ErrorDocument 404 /404.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) www.mysite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^([^ \.]+)\.mysite\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.mysite\.com(.*)$ [NC]
RewriteRule ^(.*)$ index.php?domainname=%1%2 [L,QSA]
I apologize if something is not very clear.
Thank you in advance.
Answer the question
In order to leave comments, you need to log in
achieved the fulfillment of n 4
ErrorDocument 404 /404.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) www.mysite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^([^\.] +)\.mysite\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.mysite\.com(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^/alldomains
RewriteRule ^(.*)$ /alldomains%{REQUEST_URI}index.php?name=%1%2 [L,QSA]
it remains to do item 5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question