简体   繁体   中英

Internal Server Error htaccess

I have htaccess line as per below:-

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

The problem is if I comment RewriteRule ^(.*)$ $1.php [NC,L] , http://localhost/trip/articles/Sightseeing can be display. But I cannot display http://localhost/trip/privacy (Error: Object not found!). If I uncomment the line, I can display http://localhost/trip/privacy but cannot display http://localhost/trip/articles/Sightseeing (Error: Internal Server Error).

I already tried insert <Directory /> AllowOverride All </Directory> and got error: Server error! and insert <IfModule mod_rewrite.c>...</IfModule> and got error: Internal Server Error.

Is there any way for both link be display successfully? Thanks in advance.

I already solved it. For those who have same problem as mine:-

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM