2014-01-15 50 views
0

我想重定向我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

任何想法如何添加「子域」?

Thnx!

回答

0

最有可能你有MultiViews啓用。

關掉它使用之上這一行你.htaccess

Options +FollowSymlinks -MultiViews 
RewriteEngine On 
RewriteBase/

RewriteRule ^nieuws/([^.]+)\.html$ /nieuws.php?id=$1 [L,QSA] 
+0

沒有遺憾,當我這樣做,我得到一個404未找到... – ZarkoRSK

+0

嘗試代碼在上面輸入我的回答你的DocumentRoot內/.htacces – anubhava