htAccess 抛出 500 错误


htaccess throwing 500 error

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^read(.+)?$ /read.php?id=$1 [QSA,L]
RewriteRule ^chapter(.+)?$ /readchapter.php?id=$1 [QSA,L]
RewriteRule ^list(.+)?$ /list.php?id=$1 [QSA,L]
</IfModule>

以上是我的htaccess文件,我尝试创建一个故事阅读网站。

我试图缩短示例链接

http://read.mydomain.com/chapter/three_little_fox/

所以当它查询时

/chapter/three_little_fox

它实际上会加载readchapter.php?id=three_little_fox

但是当我尝试加载页面时

http://read.mydomain.com/chapter/three_little_fox/

它会引发内部 500 错误。

感谢您的帮助

当前的 .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^chapter/([^/]*)$ readchapter.php?id=$1 [L]
</IfModule>

但是404错误存在,我的文件夹是这样的

.htaccess
readchapter.php
index.php

试试这个

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^chapter/(.*)/?$ /readchapter.php?id=$1 [QSA,NC,L]
</IfModule>

RewriteCond(重写条件(确保如果请求已经针对文件或目录,则将跳过 RewriteRule。

这将适用于您:

RewriteEngine On
RewriteRule ^chapter/([^/]*)$ /readchapter.php?id=$1 [L]