如何使用.htaccess php创建子域

时间:2016-02-23 18:14:42

标签: php apache .htaccess redirect

我想使用htaccess创建子域。 目前我的网址如下所示

  

http://example.com/test.php?id=sub

。我想将我的网址更改为

  

http://sub.example.com/test.php

帮助我解决这个问题的任何其他方法。

  

我尝试过以下代码但不能正常工作

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com/test.php?id=$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([a-z0-9-]+)/? http://$1.example.com [R=301,NC,L]

任何人都可以帮助我。

0 个答案:

没有答案
相关问题