2013-10-14 2 views
0

내 서버의 public_html/subdomain 폴더에 와일드 카드 하위 도메인이 있습니다. 다음과 같이 난 그냥 페이지에 뭐하는 거지을 보여 PHP 스크립트를 사용하고 있습니다 :서버의 폴더에서 와일드 카드 하위 도메인을 사용하는 방법 public_html/subdomain

<?php 
$subdomain = explode('.', $_SERVER['HTTP_HOST']); 
$subdomain = strtolower(array_shift($subdomain)); 
echo ucwords(str_replace('-', ' ', $subdomain)); 
?> 

문제는 최상위 수준으로 public_html/인덱스를 반환에 example.domain.co.uk가 입력 될 때입니다. PHP 파일이 아니라으로 public_html/하위 도메인/index.php에

I했습니다이 전에 근무하지만

이 일을 할 수있는 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 
+0

는 당신이 지금에게 htaccess로 파일을 가지고 있습니까? –

답변

2

htaccess로 파일은 다음과 같이 보일 것이다 :

RewriteCond %{HTTP_HOST} !^(www\.)?domain\.co\.uk$ [NC] 
RewriteCond %{HTTP_HOST} ^([^.]+)\. 
RewriteCond %{REQUEST_URI}::%1 !^/([^/]*)/?(.*)::\1 
RewriteRule ^(.*)$ /%1/$1 [L] 
+0

내가 현재 가지고있는 것에 대해 위의 편집을 참조하십시오. –

+0

public_html 또는 public_html/subdomain 폴더에이 htaccess를 두는가? –

+0

@JosephNaylor 당신은'public_html' 디렉토리에 이것을 넣고 싶습니다. –

관련 문제