2011-04-07 160 views
0

我主持了一個使用zend框架的應用程序。並且我在公共文件夾中有.htaccess文件來重定向所有請求以通過index.php。它正在工作,但我沒有在應用程序中獲取請求參數。爲什麼是這樣?htaccess重定向

RewriteEngine on 
Options +FollowSymlinks 

RewriteBase/
RewriteRule !\.(js|ico|txt|gif|GIF|jpg|png|PNG|css|xml|JPG)$ 

index.php 
+0

你是如何確定你是不是收到請求的文件類型的所有請求參數?你能發佈一個示例請求和你期望的代碼嗎? – Phil 2011-04-07 06:35:28

回答

1

這不是一個非常強大的解決方案。如果請求的文件擴展名不包含在列表中,會發生什麼情況?

標準ZF 1.11規則要好得多

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 
+0

獲取服務器錯誤 – Vir 2011-04-07 05:27:23

+0

@Vir什麼是錯誤信息?它將在你的Apache錯誤日誌中。 – Phil 2011-04-07 06:09:06

+0

RewriteEngine敘述上 選項+了FollowSymLinks RewriteBase/ 的RewriteCond%{REQUEST_FILENAME} -s [OR] 的RewriteCond%{REQUEST_FILENAME} -1- [OR] 的RewriteCond%{REQUEST_FILENAME} -D- 重寫規則^ * $ - [NC, L] RewriteRule ^。* $ index.php [NC,L] 仍然沒有getring請求參數 – Vir 2011-04-07 06:23:00

1

這將通過排除上市的index.php

RewriteCond %{REQUEST_FILENAME} !\.(js|ico|txt|gif|GIF|jpg|png|PNG|css|xml|JPG)$ 
RewriteRule (.*)$ http://domain.com/index.php$1 [R=301,L] 
+0

另外,如果你想縮短你的網址,也許嘗試這樣做: 'RewriteRule ^(。*)\。htm $ /index.php?p = $ 1' – 2011-04-07 05:01:36

+0

獲取錯誤錯誤 – Vir 2011-04-07 06:13:49