Php 页面不显示时出现内部服务器错误';不存在

Php 页面不显示时出现内部服务器错误';不存在,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我刚刚意识到,如果您手动在URL栏中键入我的站点上不存在的页面,该站点将以内部服务器错误进行响应 是否应该是找不到的404页 例如,我的站点将返回服务器错误 这是我在处理.htaccess文件时经常遇到的一个错误,所以我在下面发布了我的错误 RewriteEngine On Options +FollowSymLinks # Add WWW to URL RewriteCond %{HTTP_HOST} ^cristianrgreco\.com$ [NC] RewriteRule ^(.*)

我刚刚意识到,如果您手动在URL栏中键入我的站点上不存在的页面,该站点将以内部服务器错误进行响应

是否应该是找不到的404页

例如,我的站点将返回服务器错误

这是我在处理.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]

提前感谢您的帮助。

我以前遇到过这个问题,问题是这一行

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

RewriteRule^([^\.]+)$$1.php[NC,L,QSA]
替换它似乎是个好办法。括号表示任何匹配的内容都将被重写规则记住。括号内写着
“我想要一个或多个不是点的字符”。

<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>

选项+FollowSymLinks
选项+索引
重新启动发动机
#将WWW添加到URL
RewriteCond%{HTTP_HOST}^cristianrgreco\.com$[NC]
重写规则^(.*)$http://www.cristianrgreco.com/$1[L,R=301]
#从URL末尾删除尾部斜杠
重写cond%{HTTP_HOST}!^\。cristianrgreco\.com$[NC]
重写规则^(+)/$http://%{http_HOST}/$1[L,R=301]
#重写文章URL
重写规则^articles/([a-zA-Z0-9_-]+)/?$articles.php?article=$1
#从PHP文件中删除文件扩展名
重写cond%{REQUEST_FILENAME}-F
重写cond%{SCRIPT_FILENAME}-D
重写规则^([^\.]+)$$1.php[NC,L,QSA]

你可以试一试。绝对聪明,我自己永远也想不到。非常感谢!