URI переписать на поддомен

Я пытаюсь изменить URI на поддомен. как изменить www.domain.com/auth/signin в login.domain.com

У меня есть виртуальный хост, как это:

<VirtualHost 127.0.0.5:80>
   DocumentRoot "path/to/root/public"
   ServerName domain.local
   ServerAlias *.domain.local
</VirtualHost>

а также .htaccess

RewriteEngine On
php_flag display_errors 1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

RewriteCond %{HTTP_HOST} !^domain.local
RewriteCond %{HTTP_HOST} ^(.+).domain.local
RewriteRule ^login/?$ http://domain.local/auth/signin [P,L,QSA]

1 ответ

1: стандартная версия http:

RewriteEngine On
php_flag display_errors 1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

# If the url is not http://domain.local (Added [NC])
RewriteCond %{HTTP_HOST} !^domain\.local [NC]

# If the url is not http://www.domain.local (Added [NC])
RewriteCond %{HTTP_HOST} !^www\.domain\.local [NC]

# Redirect
RewriteRule ^login(.*)$ http://domain.local/auth/signin$1 [R=301,L,NC]

http://sub1.domain.local/login для http://domain.local/auth/signin

http://sub2.domain.local/login для http://domain.local/auth/signin

http://sub2.domain.local/login?token=1 до http://domain.local/auth/signin?token=1

2: (необязательно) обнаружение http или https

RewriteEngine On
php_flag display_errors 1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

# If the url is not http(s)://domain.local (Added [NC])
RewriteCond %{HTTP_HOST} !^domain\.local [NC]

# If the url is not http(s)://www.domain.local (Added [NC])
RewriteCond %{HTTP_HOST} !^www\.domain\.local [NC]

# http or https detection
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTPS}:s on:(s) 

# Redirect
RewriteRule ^login(.*)$ http%1://domain.local/auth/signin$1 [R=301,L,NC]

http://sub1.domain.local/login для http://domain.local/auth/signin

https://sub1.domain.local/login для https://domain.local/auth/signin

http://sub2.domain.local/login для http://domain.local/auth/signin

https://sub2.domain.local/login для https://domain.local/auth/signin

http://sub2.domain.local/login?token=1 до http://domain.local/auth/signin?token=1

https://sub2.domain.local/login?token=1 до https://domain.local/auth/signin?token=1

Другие вопросы по тегам