2011-12-23 105 views
-1

我正在使用WampServer 2.2a-x32,我试图在我的webroot文件夹中使用.htaccess文件。WampServer 2.2a-x32 .htaccess不工作

我有rewrite.php文件,这里是它的代码

<h2 align=center> 
<?php 
// mod_rewrite Test Page 
if($_GET['link']==1){echo"You are not using mod_rewrite";} 
elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";} 
else{echo" mod_rewrte Test ";} 
?> 
</h2> 

<hr> 

<head>  
</head> 

<body> 
<p><a href="rewrite.php?link=1">LINK1</a> = rewrite.php?link=1</p> 
<p><a href="link2.html">LINK2</a> = link2.html</p>  
</body> 
</html> 

我有.htaccess文件,这里是它的代码

RewriteEngine On 
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L] 

在我的http.conf文件,我有

LoadModule rewrite_module modules/mod_rewrite.so uncommented (without #) 

和我的Apache配置为听8080端口不知道是否它的问题。

所以,如果我打的链接http://localhost:8080/test/rewrite.php我能看到的页面,但我击球的时候链接2 mod_rewrite的似乎不工作。我找不到 在此服务器上未找到请求的URL /test/link2.html。

我的系统是Windows 7的32倍 有什么建议?

+0

顺便说一句我也测试过在端口80,但它仍然不能正常工作 – themis 2011-12-23 13:40:04

+1

你试过enabeling [RewriteLogLevel](https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteloglevel)来获取信息在什么工作和什么不是? – Fluff 2011-12-23 14:08:38

+0

我该如何启用它? – themis 2011-12-23 14:15:02

回答

0

thanx我actualy设法解决它。问题是该文件没有被命名为corectly,而不是.htaccess它是htaccess。

0

我认为你需要添加一个RewriteBase,因为在htaccess的不位于文档根。

RewriteEngine On 
RewriteBase /test 
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]