2012-11-28 3 views
3

파일 확장자를 제거하는 URL 재 작성이 있습니다. .html 페이지에서 작동하지만 .php 개의 파일에 "404 페이지를 찾을 수 없음"오류가 표시됩니다. 여기URL 재 작성은 .html이지만 .php에는 작동하지 않습니다.

내 전체 .htaccess 파일 내가 잘못하고있는 무슨

# The following will allow you to use URLs such as the following: 
# 
# example.com/anything 
# example.com/anything/ 
# 
# Which will actually serve files such as the following: 
# 
# example.com/anything.html 
# example.com/anything.php 
# 
# But *only if they exist*, otherwise it will report the usual 404 error. 

Options +FollowSymLinks 
RewriteEngine On 

rewritecond %{HTTP_HOST} ^inaflashgraphics.com$ 
rewriterule^"http\:\/\/www\.inaflashgraphics\.com\/" [R=301,L] #4e2f2fa615667 

# Remove trailing slashes. 
# e.g. example.com/foo/ will redirect to example.com/foo 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA] 

# Redirect to HTML if it exists. 
# e.g. example.com/foo will display the contents of example.com/foo.html 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.+)$ $1.html [L,QSA] 

# Redirect to PHP if it exists. 
# e.g. example.com/foo will display the contents of example.com/foo.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.+)$ $1.php [L,QSA] 

입니까?

+0

RewriteLog를 추가하고 RewriteLogLevel을 5로 설정하여 단계별로 볼 수 있도록하는 것이 좋습니다. – GarethL

+0

확실하지 않은 방법 – jardane

+0

"RewriteEngine On"다음에 "RewriteLog/path/to/your/new/log"및 "RewriteLogLevel 5"행을 별도의 행에 추가하십시오. 이렇게하면 지정한 경로에 로그 파일이 만들어지고 올바른 파일을 결정할 때 다시 쓰기 엔진이 만드는 모든 단일 단계가 기록됩니다. 분명히 문제를 해결했을 때 이것을 제거하는 것을 기억하십시오! – GarethL

답변

0

당신은 시도 할 수 있습니다 :

RewriteCond %{HTTP_HOST} ^www\.inaflashgraphics\.com 
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP 
RewriteRule (.*)\.php$ $1 [R=301] 
+0

아니요, 작동하지 않았습니다. – jardane

+0

html 비트 앞에 붙이려고 시도 – boruch

+0

그냥 시도했는데 – jardane

0

내가 그것을 알아 냈다,이 코드는 나를 위해 작동합니다.

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 

rewritecond %{HTTP_HOST} ^inaflashgraphics.com$ 
rewriterule^"http\:\/\/www\.inaflashgraphics\.com\/" [R=301,L] 

RewriteBase/

## hide .php extension 
# To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule^%1 [R,L,NC] 

## To internally redirect /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule^%{REQUEST_URI}.php [L] 

# Redirect to HTML if it exists. 
# e.g. example.com/foo will display the contents of example.com/foo.html 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.+)$ $1.html [L,QSA] 
관련 문제