IIS7+、Apache、Nginx二级目录301重定向到二级域名伪静态规则
让 http://www.abc.com/m 重定向到 http://m.abc.com
二级目录301重定向到二级域名伪静态规则各种环境下的写法
以下规则放在主域名规则文件里
IIS7+ (web.config)
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="二级目录301重定向到二级域名" stopProcessing="true"> <match url="^m/(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Redirect" url="http://m.abc.com/{R:1}"/> </rule> </rules> </rewrite> </system.webServer> </configuration>
Apache (.htaccess)
RewriteEngine On RewriteBase / RewriteRule ^m/(.*)$ http://m.abc.com/$1 [R=301,L]
Nignx (nginx.conf)
location ~* ^/m/ { rewrite ^/m/(.*)$ http://m.abc.com/$1 permanent; }