Answer the question
In order to leave comments, you need to log in
How to redirect a subdomain to one page using htaccess?
There is a site: site.ru
There is a subdomain for this site: sub.site.ru
There are pages: index.php, sub.php
htaccess for the main site is configured as follows (works as it should):
RewriteRule ^status/([^/]+)/?$ index.php?action=weekly&status=$1 [L]
RewriteRule ^status/?$ index.php?action=weekly [L]
RewriteCond %{HTTP_HOST} ^sub\.([^/]+)\.ru/? [NC]
RewriteRule ^(.*)/([^/]+)/?$ sub.php?action=weekly&status=$1 [L]
RewriteRule ^(.*)/?$ sub.php?action=weekly [L ]
Answer the question
In order to leave comments, you need to log in
well, for starters, a little theory
? - and then this is a GET parameter, it is not part of the RequestURI and, as a result, is not visible to them at all, so redirects using GET parameters need to be done differently, and in addition, escape special characters, they are for this
\?
\/=
RewriteCond %{HTTP_HOST} ^(www\.|)sub\.(.+) [NC]
#Если хост www.sub или sub.и далее хотябы один символ, плюс все регистронезависимое
RewriteRule ^(.*)$ http://sub.php\?action\=weekly\&status\=$1? [L]
#то выделяем все что там после домена в группу1 и не забывая экранировать спецсимволы подставляем в урл, плюс в конце стоит вопрос, это блядство удалит гет параметры выставленные до этого ;)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question