Php 如何在服务器public_html/subdomain上的文件夹中使用通配符子域
我在服务器上的public_html/subdomain文件夹中有一个通配符子域。我使用的php脚本如下 只是想在页面上向您展示我在做什么:Php 如何在服务器public_html/subdomain上的文件夹中使用通配符子域,php,.htaccess,mod-rewrite,subdomain,wildcard,Php,.htaccess,Mod Rewrite,Subdomain,Wildcard,我在服务器上的public_html/subdomain文件夹中有一个通配符子域。我使用的php脚本如下 只是想在页面上向您展示我在做什么: <?php $subdomain = explode('.', $_SERVER['HTTP_HOST']); $subdomain = strtolower(array_shift($subdomain)); echo ucwords(str_replace('-', ' ', $subdomain)); ?> 问题是,当输入e
<?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
重写cond%{HTTPS}=在…上
重写cond%{HTTP_HOST}^www\.(.+)$[NC]
重写规则^http://%1%{REQUEST_URI}[R=301,L]
允许从148.204开始。
允许从googlebot.com google.com
满足任何
新代码
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
重新编写引擎打开
#-首页-
IndexIgnore.htaccess*/.??**~*#*/HEADER**/README**/\u vti*
命令拒绝,允许
全盘否定
通融
命令拒绝,允许
全盘否定
AuthName domain.co.uk
AuthUserFile/home/**/public_html/_vti_pvt/service.pwd
AuthGroupFile/home/**/public\u html/\u vti\u pvt/service.grp
重新启动发动机
重写cond%{HTTPS}=在…上
重写cond%{HTTP_HOST}^www\.(.+)$[NC]
重写规则^http://%1%{REQUEST_URI}[R=301,L]
允许从148.204开始。
允许从googlebot.com google.com
满足任何
重新启动发动机
重写基/
重写cond%{HTTP_HOST}^www\.domain\.co.uk[NC]
重写规则(.*)http://domain.co.uk/$1[R=301,L]
重新启动发动机
重写基/
重写cond%{HTTP_HOST}^(www\)?域名\.co\.uk$[NC]
重写cond%{HTTP\u HOST}^([^.]+)\。
重写条件%{REQUEST_URI}::%1^/([^/]*)/?(.*)::\1
重写规则^(.*)$/%1/$1[L]
错误文档404/404.html
htaccess文件应如下所示:
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.co\.uk$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteCond %{REQUEST_URI}::%1 !^/([^/]*)/?(.*)::\1
RewriteRule ^(.*)$ /%1/$1 [L]
你现在有什么htaccess文件?我把这个htaccess放在public\u html或public\u html/子域文件夹中吗?@JosephNaylor你想把它放在你的
public\u html
目录中。这仍然会打开我的public\u html/index.php页面,而不是public\u html/subdomain/index.php-我把你所有的东西都放在我的htaccess中,什么都没有elsedo我必须在上面加一个modrewrite什么的?@JosephNaylor是的,你需要在上加一个重写引擎,并确保你的httpd.conf中加载了mod_rewrite。我认为你已经做了所有这些事情,因为你已经在使用规则了