我需要满足两个条件才能使用mod_rewrite执行特定的操作:
我认为(/希望)这很简单,但我完全不了解mod_rewrite。任何帮助将不胜感激。谢谢!
答案 0 :(得分:0)
有效的事情
RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin.something.com$
RewriteRule ^(.*)$ http://something.com/admin [L]
RewriteCond %{HTTP_HOST} !^something.com$
RewriteRule ^(.*)$ http://something.com/index.php?school=$1 [L]
答案 1 :(得分:0)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^admin\.something\.com
RewriteRule ^(.*)$ /admin/$1 [L]
RewriteCond %{HTTP_HOST} !^something.com$
RewriteRule ^(.*)$ /index.php?school=$1 [L]
答案 2 :(得分:0)
RewriteCond %{HTTP_HOST} ^admin\.something\.com
RewriteRule .* http://something.com/admin [L,R=301]
我会在php代码中将subdomain.something.com重定向到something.com/index.php?school=subdomain,例如
header('Location: something.com/index.php?school='.$retreived_from_http_host_subdomain);
因为我不知道如何在RewriteRule
内获取域名(也许有人会在这里发布答案)