R
R
rivalsm2014-09-04 17:43:23
Apache HTTP Server
rivalsm, 2014-09-04 17:43:23

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]

If "tula/" is changed to any absolute address like http://ya.ru, then a redirect to the address happens.
From this I conclude that there is some problem with internal addressing and, possibly, with RewriteBase.
At the moment, manipulations are performed with .htaccess, which lies in a directory higher than the directory of the main domain and subdomains.
What could actually be the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Vasiliev, 2014-09-04
@qmax

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 /

A
Anton Solomonov, 2014-09-05
@Wendor

RewriteEngine On
RewriteCond %{HTTP_HOST} ^tula\.domain\.ru$
RewriteRule ^(.*)$ http://domain.ru/tula/$1 [L,NC,QSA]

R
rivalsm, 2014-09-04
@rivalsm

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 question

Ask a Question

731 491 924 answers to any question