2015-01-22 6 views
0

웹 루트 (public_html) 디렉토리에서 .htaccess 파일을 편집하여 내 웹 사이트의 URL에서 .html 확장자를 제거하려고합니다. 내 서버는 블루 호스트입니다.URL에서 .html 확장자를 제거하십시오.

문제점은 .htaccess 파일에서 이미 기본 도메인을 하위 디렉토리 용도로 리디렉션하기 위해 이전 설정이 있다는 것입니다.

스크립트는 다음과 같습니다. 또한 스크립트에서 나는 URL에서 확장 기능을 숨겨서 온라인에서 찾았습니다. (스크립트가 작동하지 않습니다.) 누군가가 문제를 해결할 수 있다면 정말 좋을 것입니다. 감사.

# Use PHP5.4 Single php.ini as default 
AddHandler application/x-httpd-php54s .php 


# 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.)?qinglish.ca$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/qinglish_ca/ 
# 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 ^(.*)$ /qinglish_ca/$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.)?qinglish.ca$ 
RewriteRule ^(/)?$ qinglish_ca/index.html [L] 

Options -MultiViews 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html !-f 
RewriteRule ^([^\.]+)$ $1.html [NC,L] 
+0

정확히 작동하지 않는 항목은 무엇입니까? – anubhava

+0

.html 확장자는 여전히 – Qing

답변

2

하는 대신 마지막 규칙의 당신은 이리저리 모든 URL을 .html 확장을 제거하려면 다음 규칙이 필요합니다 : 당신이 .html 확장을 추가 할 수있는 현재의 규칙이 같은 장소에서

## hide .html extension 
# To externally redirect /dir/file.html to /dir/file 
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC] 
RewriteRule^/%1 [R=302,L,NE] 

# To internally forward /dir/file to /dir/file.html 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.html -f [NC] 
RewriteRule ^(.+?)/?$ /$1.html [L] 

장소를.

+0

입니다. 정말 고마워요. :) 고마워요! – Qing

+0

안녕하세요. 스크립트를 사용하여 모든 기능이 완벽하게 작동하도록해서 죄송합니다. 동일한 도메인 아래에있는 다른 하위 디렉터리 페이지에 연결 문제가 있음을 알았습니다. 이 페이지의 링크가 작동하지 않는 것처럼 [link] (http://www.qinglish.ca/cn/#/portfolio), [link] (http://www.qinglish.ca/cn/portfolio-item-02.html). 어쨌든 그것을 고칠 수 있습니까? @anubhava – Qing

+0

안녕하세요. 내가 잘못 놓았는지 잘 모르겠습니다.이 [link] (https://dl.dropboxusercontent.com/u/2798477/temp/index.html)로 가서 알려주세요. , 고마워요 :) – Qing

관련 문제