2014-09-24 2 views
0

내 htaccess 코드에 문제가 있다고 생각하지만 알아낼 수 없습니다.Htacess를 사용하여 폴더 이름 제거

내가 필요한 것은 무엇입니까?

1) 폴더 이름을 제거) www.domain.com/index 대신 www.domain.com/index.php

이 같은 주소에서 .PHP 확장자를 제거합니다. 내 웹 사이트 파일은 public이라는 폴더에 저장됩니다. 나는 그것을 제거하고 싶다. www.domain.com/public/index.php to www.domain.com/index

다음 코드를 작성했습니다.이 문제에 대해 알려주십시오.

# This will hide the folder name public and the php text 
Options +FollowSymLinks -MultiViews 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule (.*) $1\.php [L] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+public/([^\s]+) [NC] 
RewriteRule^%1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
# if you face any problem than try to uncomment the below line and delete the line after it 
RewriteRule (?!^public/)^(.*)$ public/$1 [L,NC] 
+0

가능한 중복 : ([htaccess로와 확장을 .PHP 제거] http://stackoverflow.com/questions/4026021/remove-php -extension-with-htaccess) – Azrael

+0

1)'Options + MultiViews'를 사용하십시오 – Phil

+0

누군가가 downvoted 이유를 말해 줄 수 있습니까? – user3477550

답변

0

이 같은 규칙을 가질 수 있습니다

# This will hide the folder name public and the php text 
Options +FollowSymLinks -MultiViews 
RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} \s/+public/(\S+) [NC] 
RewriteRule^%1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
# if you face any problem than try to uncomment the below line and delete the line after it 
RewriteRule ^((?!public/).*)$ public/$1 [L,NC] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/public/$1\.php -f [NC] 
RewriteRule ^(.+?)/?$ $1.php [L] 
+0

감사합니다 anubhava,하지만 이것을 확인합니다. 작동하지 않습니다. 본문을 편집하여 읽으십시오 ... – user3477550

+0

어떤 URL에서 작동하지 않습니까? '/ public/.htaccess' 파일도 가지고 있습니까? – anubhava

+0

브라우저에'www.domain.com/index'을 입력하면 어떻게됩니까? – anubhava

관련 문제