htaccess通配符子域重写没有infinate循环

时间:2021-12-31 07:42:15

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. This is the script in my .php file for this

我想要anything.domain.co.uk去一个php脚本,然后使用html中的url中的'anything'来创建不同的标题。这是我的.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

我使用了下面的脚本,但它显然创建了一个循环。我怎么得到任何东西.domain.co.uk拿起PHP脚本,仍然有ur.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]

1 个解决方案

#1


0  

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> 

#1


0  

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>