0

サーバーの 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/subdomain/index.php ではなく、最上位の public_html/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
4

1 に答える 1