2013-03-06 97 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