WampServer 2.2a-x32 .htaccess not working

我的未来我决定 提交于 2019-12-13 23:25:49

问题


i am using WampServer 2.2a-x32 and i am trying to use .htaccess file in my webroot folder.

i have rewrite.php file and here is its code

<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> 

i have .htaccess file and here is its code

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

in my http.conf file i have

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

and my Apache is configured to listen to 8080 port not sure if its the issue.

So if i hit the link http://localhost:8080/test/rewrite.php i get to see the page but when i hit link2 mod_rewrite doesn't seem to work. i get Not Found The requested URL /test/link2.html was not found on this server.

My system is windows 7 x32 any suggestions ?


回答1:


I think you need to add a RewriteBase, because the htaccess in not located in the document-root.

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



回答2:


thanx i actualy managed to fix it. The problem was that the file was not named corectly, instead of .htaccess it was htaccess.



来源:https://stackoverflow.com/questions/8616717/wampserver-2-2a-x32-htaccess-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!