2013-03-06 44 views
0

,所以我有這個在我的.htaccess文件htaccess的mod_rewrite的給我404

RewriteEngine On 
RewriteBase /core/ 
RewriteCond %{QUERY_STRING} ^page=([0-9]+)$ 
RewriteRule ^page page/%1/? [L] 

我的網址是

http://localhost/core/page.php?page=8 

與應用的規則我得到..

Not Found 
The requested URL /core/page/8/ was not found on this server. 

這是在wampserver上運行2.2

文件結構看起來像

c:/wamp/www/core 

.htaccess位於/ core /目錄中。 什麼是我失蹤..我檢查了我的apache.conf文件,它看起來很好。

+0

等等,我很困惑。您正試圖將**/core/page/8/**改寫爲**/core/page.php?page = 8 **對嗎?看到我更新的答案。 – kjetilh 2013-03-06 07:28:23

回答

2

我想你錯了。當邏輯思維重寫你不重寫原始URL新的URL(例如page.php文件?頁= 8頁/ 8/)你居然改寫頁/ 8/page.php?page = 8。你告訴服務器它應該如何解釋不熟悉的URL。

所以,如果我理解正確,您想達到什麼是:

  1. 用戶訪問本地主機/核心/頁/ 8/
  2. 用戶是擔任(引擎蓋下)localhost/core/page.php?page = 8

我相信下面的RewriteRule會做的伎倆(查詢字符串的條件是沒有必要的):

RewriteRule ^page/(\d+)/$ page.php?page=$1 [L] 
+0

我是個白癡謝謝。 – user1620152 2013-03-06 14:50:18