[英]Web site link change using HTAaccess
Is it possible to use .htaccess to rewrite a sub domain?是否可以使用 .htaccess 重写子域?
Example:例子:
http://fashion.example.com
shows the content of http://fashion.example.com
显示的内容
http://example.com/index.php?name=fashion
<IfModule mod_rewrite.c>
# Turn on the rewrite engine
RewriteEngine on
RewriteRule %{REQUEST_URI} ^(.*).example.com/$ index.php?name=$1
</IfModule>
Assuming your subdomain is pointing to the same directory as your main domain, you can use something like the following:假设您的子域指向与主域相同的目录,您可以使用如下内容:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^((?!www).+)\.example.com$
RewriteRule ^(.+)/?$ /index.php?name=%1 [L]
You may try this rule:你可以试试这个规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.example\.com$ [NC]
RewriteRule ^ index.php?name=%1 [L,QSA]
``
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.