2014-03-19 111 views
0

我有一個網站,可以打開多個獲得Resquests和沒有一個。.htaccess RewriteEngine與各種查詢字符串

所以有

?組= X,?ID = X,?公頃= X

它們都可以在同一時間被使用,或僅1或2的他們。

我想重寫我http://www.example.com/test.php .... 到http://www.example.com/example

?例如:

所以當我打開www.example.com/test.php?group=x & ID = Y
應當顯示爲www.example.com/example

當我打開www.example.com/test.php?ha=z
也應該顯示www.example.com/example

這可能與mod_rewirte?

回答

0

你可以嘗試把一個規則在您的.htaccess文件是這樣的:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    RewriteCond %{REQUEST_URI} ^test.php.*$ [NC] 
    RewriteRule ^test.php.*$ example [L] 
</IfModule> 

它應該只適用於與/test.php開始,所有的人都重定向到http://wwww.yoursite.com/example請求。

用這種方法你將失去查詢字符串參數,除非你使用clean URLs來傳遞它們,你必須使用htaccess進行配置。