我的服务器上的 public_html/subdomain 文件夹中有一个通配符子域。我正在使用 php 脚本,如下所示只是为了向您展示我在页面上所做的事情:
<?php
$subdomain = explode('.', $_SERVER['HTTP_HOST']);
$subdomain = strtolower(array_shift($subdomain));
echo ucwords(str_replace('-', ' ', $subdomain));
?>
问题是当 example.domain.co.uk 被输入时,它返回顶级 public_html/index.php 文件而不是 public_html/subdomain/index.php
我以前有这个工作,但我可能错误地更改了 .htaccess
.htaccess 文件中应该包含什么才能使这项工作?
我目前有:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
Allow from 148.204.
Allow from googlebot.com google.com
satisfy any
新代码
RewriteEngine On
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName domain.co.uk
AuthUserFile /home/****/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/****/public_html/_vti_pvt/service.grp
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
Allow from 148.204.
Allow from googlebot.com google.com
satisfy any
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.co.uk [NC]
RewriteRule (.*) http://domain.co.uk/$1 [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.co\.uk$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteCond %{REQUEST_URI}::%1 !^/([^/]*)/?(.*)::\1
RewriteRule ^(.*)$ /%1/$1 [L]
ErrorDocument 404 /404.html