簡體   English   中英

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

這將為您工作:

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

嘗試這個

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM