[英]htaccess wildcard subdomain rewrite without infinate loop
I want anything.domain.co.uk to go to a php script which then uses the 'anything' from the url within the html to create different headers for example. 我想将any.domain.co.uk转到php脚本,然后使用html中url中的“任何内容”来创建不同的标头。 This is the script in my .php file for this
这是我的.php文件中的脚本
<?php echo array_shift(explode(".",$_SERVER['HTTP_HOST']));?>
I have used the script below but it creates a loop obviously. 我使用了以下脚本,但显然会创建一个循环。 How do I get anything.domain.co.uk to pick up the php script, still have anything.domain.co.uk in the url and also have www.domain.co.uk go to 'normal' index page
我如何获取something.domain.co.uk来获取php脚本,仍然在URL中包含everything.domain.co.uk,并让www.domain.co.uk转到“常规”索引页
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.domain.co.uk$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.co.uk [NC]
RewriteRule (.*) http://%2.domain.co.uk/$1 [R=301,L]
You can use the Location directive to locate the script you want to target and the use an Allow from to limit access to certain domains: 您可以使用Location指令找到要定位的脚本,并使用Allow from来限制对某些域的访问:
<Location /script.php>
Order Deny,Allow
Deny from all
Allow from anything.domain.co.uk
</Location>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.