2014-03-26 3 views
0

www.example.org.uk을 example.org.uk/subdirectory로 리디렉션 한 다음 하위 디렉토리를 숨기려고합니다. 따라서 주소 표시 줄에 www.example.org.uk 만 표시됩니다.루트 폴더를 하위 디렉토리로 리디렉션하고 GoDaddy에서 .Htaccess를 사용하여 숨기는 방법?

이 내가 사용되었다 (https://my.bluehost.com/cgi/help/347에서) 원래의 코드는 다음과 같습니다

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?example.org.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/subdirectory/ 
# Don't change the following two lines. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteRule ^(.*)$ /subdirectory/$1 
# Change example.com to be your main domain again. 
# Change 'subdirectory' to be the directory you will use for your main domain 
# followed by/then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?example.org.uk$ 
RewriteRule ^(/)?$ subdirectory/index.php [L] 

문제는이 코드의 어느 것도 작동하지 않는다는 것이다. -

유래를 검색하고 조언을 사용한 후이 현재 코드 : 불행하게도 내부 오류가 표시됩니다

Options +FollowSymLinks -Multiviews 

<IfModule mod_rewrite.c> 

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?grampianyoga.org.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/gya2/ 
# Don't change the following two lines. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteRule ^(.*)$ /gya2/$1 
# Change example.com to be your main domain again. 
# Change 'subdirectory' to be the directory you will use for your main domain 
# followed by/then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?grampianyoga.org.uk$ 
RewriteRule ^(/)?$ gya2/index.php [L]</IfModule> 

이 오류 파일 상태는 I GoDaddy를 사용하고 :[Wed Mar 26 14:22:35 2014] [9566783] [core:alert] [client 97.74.104.6:60525] /var/chroot/home/content/83/9566783/html/.htaccess: RewriteRule: bad flag delimiters

그리고 나는 그들이 믿는 것을 자신의 설정을 가지고 있습니다. 누구든지 어떤 제안이 있습니까? 시도한 지원 및 분명히 그들은 스크립팅을 도울 수 없습니다.

+0

'RedirectMatch ^/foo/$/foo/bar /'또는'RedirectMatch ^/foo/$/bar/baz /'디렉토리의 상위 디렉토리에'.htaccess' 파일을 추가해보십시오. . [apache2를 하위 디렉토리로 리디렉션하는 방법] (http://serverfault.com/q/9992/145545)을 참조하십시오. – jww

답변

1

나는 후행가/선택입니다 그래서

RewriteCond %{REQUEST_URI} !^/subdirectory/? 

에 선

RewriteCond %{REQUEST_URI} !^/subdirectory/ 

을 변경합니다. 코드가 -f-d 인 경우 기존 파일 또는 디렉토리를 제공하는 경우 트리거되지 않습니다.

RewriteRule ^(.*)$ /subdirectory/$1 

는 자동으로 하위 디렉토리 (기존 URI 전에 삽입/하위 디렉토리)에 방문자를 보내야하지 ​​가정.

나는 왜 마지막 두 줄이 거기에 있는지 잘 모르겠습니다. 후행/요구 사항을 없애면 (이미 언급 한 것처럼) 이미 처리 될 수 있습니다. 주석을 달아보십시오 (# 표시).

여전히 작동하지 않으면 GoDaddy의 설정에 따라 다른 것이있을 수 있습니다. 기술 지원으로 무엇을하려고하는지 토론해야합니다.

업데이트 : 당신이 등 추가 기능 도메인, 주차 도메인, 하위로 작업하지 않는 한 RewriteCond %{HTTP_HOST} ^(www\.)?grampianyoga\.org\.uk$ 라인은 불필요한 (그러나 무해한) 아마

Options +FollowSymLinks -Multiviews 

<IfModule mod_rewrite.c> 

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www\.)?grampianyoga\.org\.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/gya2 
RewriteRule ^(.*)$ /gya2/$1 [L] 

</IfModule> 

최신의 .htaccess의 수정 된 버전

+0

여전히 작동하지 않습니다. 오류 로그에 다음과 같은 메시지가 표시됩니다. [Wed Mar 26 14:22:35 2014] [9566783] [core : alert] [client 97.74.104.6:60525]/var/chroot/home/content /83/9566783/html/.htaccess : RewriteRule : 잘못된 플래그 구분 기호 다른 제안 사항이 있습니까? –

+0

잘못된 플래그 구분 기호? .htaccess는 이제 어떻게 생겼습니까 (첫 번째 게시물 하단에 추가하십시오). .htaccess에서 그 메시지를 본 적이 없습니다. –

+0

원래 게시물을 수정했습니다.희망이 도움이됩니다. –

관련 문제