如何使用 .htaccess 将用户重定向到同一网站上的新网址?
我最近更改了网站的网址。
旧网址:mysite.com/top/1
新网址:mysite.com/top/page=1
当用户访问旧网址时,我想将他们重定向到新网址。我怎样才能用.htaccess 做到这一点?
我有新网址的重写规则
RewriteRule ([top,new]+)/page=([0-9]+) index.php?h=$1&page=$2 [L]
I recently changed URLs of my site.
Old URL: mysite.com/top/1
New URL: mysite.com/top/page=1
When the users visit old url I want to redirect them to new url. How can I do it with .htaccess?
i have this rewrite rule for new url
RewriteRule ([top,new]+)/page=([0-9]+) index.php?h=$1&page=$2 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
Try this
对于你原来的问题,你应该尝试这样的事情:
但是根据你对 Virendra 帖子的评论,这可能会更好地满足你的需求:
这将匹配 top 和 new,并且仅在指定了有效页码的情况下重写。
希望这有帮助
For your original question, you should try something like this:
But according to your comment on Virendra's post, this will probably better suite your needs:
This will match both top and new, and rewrite only if a valid page number is specified.
Hope this helps