[英]simple redirect using .htaccess is not working
I'm trying to create a simple redirection that all my request for user/55
will be redirected to folder2/index2.html
我正在尝试创建一个简单的重定向,将我对
user/55
所有请求都重定向到folder2/index2.html
I'm doing on the tests on localhost running wamp. 我正在对运行wamp的localhost进行测试。 My project hierarchy is:
我的项目层次结构是:
I defined .htaccess
like that: 我这样定义
.htaccess
:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^users/55 folder2/index2.html [R=301,L]
My main page is index1.html
and it looks like that: 我的主页是
index1.html
,它看起来像这样:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Index1 page</h1>
<a href="users/55">go to second page</a>
</body>
</html>
When I pressed the link there is no redirection instead I get the error: The requested URL /redirect/folder1/users/ was not found on this server.
当我按下链接时,没有重定向,而是出现错误:
The requested URL /redirect/folder1/users/ was not found on this server.
I enabled mod_rewrite on Apache server and I see not errors in the logs. 我在Apache服务器上启用了mod_rewrite,但在日志中看不到错误。 What am I doing wrong I try to follow a simple guide and it is not working.
我在做错什么,我尝试遵循一个简单的指南,但它不起作用。
I think this is just because the url in your anchor tag is a relative url. 我认为这仅仅是因为锚标记中的网址是相对网址。
<a href="users/55">go to second page</a>
The above will link to /redirect/folder1/users/
上面将链接到
/redirect/folder1/users/
If you want to link to /redirect/users
you can try 如果要链接到
/redirect/users
,可以尝试
<a href="/redirect/users/55">go to second page</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.