内部服务器错误htaccess

时间:2014-09-07 04:40:56

标签: php apache .htaccess mod-rewrite xampp

我有htaccess行如下: -

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

RewriteRule ^articles/images/(.*)$ images/$1
RewriteRule ^articles/(.*)/images/(.*)$ images/$2

RewriteRule ^articles/([a-zA-Z0-9_-]+)$ articles.php?articleType=$1
RewriteRule ^articles/([a-zA-Z0-9_-]+)/([0-9]+)$ articles.php?articleType=$1&page=$2
RewriteRule ^articles/([a-zA-Z0-9_-]+)/(.*)$ articles.php?articleType=$1&articleID=$2

问题是,如果我评论RewriteRule ^(.*)$ $1.php [NC,L],则可以显示http://localhost/trip/articles/Sightseeing。但我无法显示http://localhost/trip/privacy(错误:未找到对象!)。如果我取消注释该行,我可以显示http://localhost/trip/privacy但无法显示http://localhost/trip/articles/Sightseeing(错误:内部服务器错误)。

我已经尝试插入<Directory /> AllowOverride All </Directory>并收到错误:服务器错误!并插入<IfModule mod_rewrite.c>...</IfModule>并收到错误:内部服务器错误。

是否有任何方法可以成功显示两个链接?提前谢谢。

1 个答案:

答案 0 :(得分:0)

我已经解决了。对于那些与我有同样问题的人: -

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ $1.php

RewriteRule ^articles/images/(.*)$ images/$1

RewriteRule ^articles/(.*)/images/(.*)$ images/$2

RewriteRule ^articles/([a-zA-Z0-9_-]+)$ articles.php?articleType=$1 [L]
RewriteRule ^articles/([a-zA-Z0-9_-]+)/([0-9]+)$ articles.php?articleType=$1&page=$2 
RewriteRule ^articles/([a-zA-Z0-9_-]+)/(.*)$ articles.php?articleType=$1&articleID=$2