Answer the question
In order to leave comments, you need to log in
Why doesn't it rewrite from a subdomain to a subfolder in the main domain?
Hello, the second day I struggle with a problem of the following character:
There is a site: domain.com. It is necessary to create several subdomains by cities in such a way that
when opening an address like http://tula.domain.ru, the data is taken from the subdirectory of the main domain like this: domain.ru/tula without changing the address (redirect).
The hosting is virtual, there is no access to the Apache config. Subdomains have been created in the control panel,
for which their own folders have been formed on the hosting. The following construct does not work correctly - Shows 500 Internal Server Error:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^tula\.domain\.ru$
RewriteRule ^(.*)$ tula/ [L]
Answer the question
In order to leave comments, you need to log in
Well, firstly, you replace any path with tula/
in general, that is, subdirectories in urls are impossible for you.
To save them, you need to replace them with tula/$1
. Secondly, if you substitute an absolute URL, then a redirect happens by definition.
Thirdly, turn on RewriteLog, RewriteLogLevel 3 and see what exactly it rewrites for you.
Fourthly, 500 can already fall out from inside your tula /
RewriteEngine On
RewriteCond %{HTTP_HOST} ^tula\.domain\.ru$
RewriteRule ^(.*)$ http://domain.ru/tula/$1 [L,NC,QSA]
I cannot register RewriteLog in htaccess, and there is no access to httpd.conf. In Apache logs, the result of the Internal Server Error output does not appear in any way. But if I enter RewriteLog, then an error is visible in the logs about the impossibility of using it. Any other ideas?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question