2011-12-12 111 views
0

我剛剛意識到,如果您要在網站欄中手動輸入網站上不存在的頁面,則該站點會響應一個內部服務器錯誤。頁面不存在時發生內部服務器錯誤

是不是404頁面未找到?

我的網站是http://www.cristianrgreco.com,例如http://www.cristianrgreco.com/example將返回一個服務器錯誤。

這是我經常在遇到.htaccess文件時遇到的錯誤,所以我在下面張貼了我的。

RewriteEngine On 
Options +FollowSymLinks 

# Add WWW to URL 
RewriteCond %{HTTP_HOST} ^cristianrgreco\.com$ [NC] 
RewriteRule ^(.*)$ http://www.cristianrgreco.com/$1 [L,R=301] 

# Remove trailing slashes from end of URL 
RewriteCond %{HTTP_HOST} !^\.cristianrgreco\.com$ [NC] 
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [L,R=301] 

# Rewrite article URLs 
RewriteRule ^articles/([a-zA-Z0-9_-]+)/?$ articles.php?article=$1 

# Remove file extension from PHP files 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ $1.php [L,QSA] 

在此先感謝您的幫助。

+0

您可以試試[臨站長(http://webmasters.stackexchange.com/)來代替。 –

回答

1

我以前也遇到過這個問題,但問題是這條線

RewriteRule ^(.*)$ $1.php [L,QSA]

RewriteRule ^([^\.]+)$ $1.php [NC,L,QSA]替換它似乎待辦事項的伎倆。括號中的括號表示任何匹配的內容都會被RewriteRule記住。括號內,它說:

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    Options +Indexes 
    RewriteEngine On 
    # Add WWW to URL 
    RewriteCond %{HTTP_HOST} ^cristianrgreco\.com$ [NC] 
    RewriteRule ^(.*)$ http://www.cristianrgreco.com/$1 [L,R=301] 

    # Remove trailing slashes from end of URL 
    RewriteCond %{HTTP_HOST} !^\.cristianrgreco\.com$ [NC] 
    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [L,R=301] 

    # Rewrite article URLs 
    RewriteRule ^articles/([a-zA-Z0-9_-]+)/?$ articles.php?article=$1 

    # Remove file extension from PHP files 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{SCRIPT_FILENAME} !-d 
    RewriteRule ^([^\.]+)$ $1.php [NC,L,QSA] 
</IfModule> 
+0

絕對的輝煌,永遠都不會想到我自己。非常感謝! – Cristian

相關問題