我尝试将URI更改为Subdomain。如何将www.domain.com/auth/signin
更改为login.domain.com
我有这样的virtualhost:
<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]
答案 0 :(得分:0)
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