2015-05-21 51 views
1

我正在用fastcgi在服務器上開發一個PHP,MVC,web應用程序。由於對FastCGI的我不得不用問號在我的重寫規則類似:FastCGI .htaccess重定向不起作用

RewriteRule ^(.*)$ index.php?/$1 [L] 

但後來當我嘗試做一個簡單的301重定向我最終重定向到一個尷尬的網址是這樣的:http://example.com/bg/home/login?/admin

我的.htaccess看起來是這樣的:

RewriteEngine On 
DirectoryIndex index.php 

RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

Redirect 301 /admin /bg/home/login 

如何做301重定向妥善任何想法?

回答

0

你應該最後的RewriteCond後面加一個例外,這個URI:如果你想擺脫查詢字符串的

RewriteCond %{REQUEST_URI} !^/bg/home/login$ 

,更好的辦法是使用重寫規則,而不是重定向它做。首先添加RewriteCond:

RewriteRule ^admin$ /bg/home/login? [R=301,L]