Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将virtualsubdomain重定向到与参数具有相同域的页面_Php_.htaccess - Fatal编程技术网

Php 将virtualsubdomain重定向到与参数具有相同域的页面

Php 将virtualsubdomain重定向到与参数具有相同域的页面,php,.htaccess,Php,.htaccess,在php代码中,我需要将所有虚拟子域重定向到具有相同子域作为参数的页面 例如,重定向自: anytext.mydomain.com 致: 如何使用htaccess文件执行此操作?试试看,它肯定会对您有所帮助: # .htaccess Options +FollowSymLinks RewriteBase / RewriteCond %{HTTP_HOST} !^www.your-domain-name.com [NC] RewriteCond %{HTTP_HOST} ^(www.)?([

在php代码中,我需要将所有虚拟子域重定向到具有相同子域作为参数的页面

例如,重定向自:

anytext.mydomain.com
致:


如何使用htaccess文件执行此操作?

试试看,它肯定会对您有所帮助:

# .htaccess

Options +FollowSymLinks
RewriteBase /

RewriteCond %{HTTP_HOST} !^www.your-domain-name.com [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).your-domain-name.com$ [NC]
RewriteRule ^([^.]+)$ /some_file.php/$1?subdomain=%2 [L,QSA]

你能发布你在htaccess文件中使用的具体内容吗?似乎还有其他问题。
# .htaccess

Options +FollowSymLinks
RewriteBase /

RewriteCond %{HTTP_HOST} !^www.your-domain-name.com [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).your-domain-name.com$ [NC]
RewriteRule ^([^.]+)$ /some_file.php/$1?subdomain=%2 [L,QSA]