WampServer 2.2a-x32 .htaccess 不工作
我正在使用 WampServer 2.2a-x32,并且尝试在我的 webroot 文件夹中使用 .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>
的代码
RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
我有 .htaccess 文件,这是我的 http.conf 文件中
LoadModule rewrite_module modules/mod_rewrite.so uncommented (without #)
,我的 Apache 配置为监听 8080 端口,不确定是否是问题。
因此,如果我点击链接 http://localhost:8080/test/rewrite.php 我得到查看该页面,但当我点击 link2 mod_rewrite 时似乎不起作用。我找不到 在此服务器上找不到请求的 URL /test/link2.html。
我的系统是windows 7 x32 有什么建议吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要添加一个 RewriteBase,因为 htaccess 不位于文档根目录中。
I think you need to add a RewriteBase, because the htaccess in not located in the document-root.
谢谢我实际上设法解决了它。问题是该文件没有正确命名,而是 htaccess,而不是 .htaccess。
thanx i actualy managed to fix it. The problem was that the file was not named corectly, instead of .htaccess it was htaccess.