[英]apache2 RewriteRule not working correctly (id=$id)
我想將nieuws.php?id = $ id重定向到/nieuws/.html
這是我的nieuws.php腳本進行測試:
<?php
if (isset($_GET["id"])) {
$id = $_GET["id"];
echo "Your ID: $id";
exit();
} else {
echo "No ID";
exit();
}
?>
為此,我在.htaccess中有以下腳本。
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^nieuws/([^/]*)\.html$ /nieuws.php?id=$1 [L]
當我打開http://localhost/nieuws/2.html
我沒有ID
但是,當我將規則更改為: RewriteRule ^nieuws([^/]*)\\.html$ /nieuws.php?id=$1 [L]
(無“子目錄”)並打開http://localhost/nieuws2.html
它有效,我得到您的ID:2
任何想法我可以添加一個“子域”嗎?
謝謝!
您很可能已啟用MultiViews
。
使用.htaccess
頂部的此行將其關閉:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^nieuws/([^.]+)\.html$ /nieuws.php?id=$1 [L,QSA]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.