[英]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>
Above is my htaccess file, I trying create a story reading website. 上面是我的htaccess文件,我尝试创建一个故事阅读网站。
I trying to shorten example link of 我试图缩短示例链接
http://read.mydomain.com/chapter/three_little_fox/
So when it query 所以当它查询
/chapter/three_little_fox
It will actually load readchapter.php?id=three_little_fox 它将实际加载readchapter.php?id = three_little_fox
But when I try load the page 但是当我尝试加载页面时
http://read.mydomain.com/chapter/three_little_fox/
It throws a Internal 500 error. 它引发内部500错误。
Thanks for helping 感谢您的帮助
The current .htaccess 当前的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^chapter/([^/]*)$ readchapter.php?id=$1 [L]
</IfModule>
But the 404 error exist, my folder is this way 但是存在404错误,我的文件夹是这种方式
.htaccess
readchapter.php
index.php
This will work for you: 这将为您工作:
RewriteEngine On
RewriteRule ^chapter/([^/]*)$ /readchapter.php?id=$1 [L]
Try this 尝试这个
<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 (Rewrite Conditions) ensures that if the request is already for a file or directory, RewriteRule will be skipped. RewriteCond(重写条件)可确保如果请求已针对文件或目录,则将跳过RewriteRule。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.