只有.htaccess的子域名

时间:2013-09-26 10:44:07

标签: .htaccess subdomain

我有url链接区域ex。 http://mysite.it/index.php?page=search&sRegion=Toscana

可以使用htaccess来制作像toscana.mysite.it这样的网址 感谢答案

这是我的htaccess:

<IfModule mod_rewrite.c> 
Options +FollowSymLinks -MultiViews
RewriteEngine On 
RewriteBase /

RewriteCond %{HTTP_HOST} ^mysite\.it$ [NC] 
RewriteCond %{QUERY_STRING} (^|&)sRegion=([^&]*) [NC] 
RewriteRule ^index\.php$ http://%2.%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

1 个答案:

答案 0 :(得分:0)

启用mod_rewrite.htaccesshttpd.conf,然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^mysite\.it$ [NC]
RewriteCond %{QUERY_STRING} (^|&)sRegion=([^&]+) [NC]
RewriteRule ^index\.php$ http://%2.%{HTTP_HOST}%{REQUEST_URI} [R=302,NC,L]