WampServer 2.2a-x32 .htaccess 不工作

发布于 2024-12-22 18:46:58 字数 1186 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷爱 2024-12-29 18:46:59

我认为您需要添加一个 RewriteBase,因为 htaccess 不位于文档根目录中。

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

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]
浪荡不羁 2024-12-29 18:46:59

谢谢我实际上设法解决了它。问题是该文件没有正确命名,而是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文