htaccess 301 重定向与 mod_rewrite
我看到了 htaccess 示例和生成器的负载来重写 url,但是我需要为一个 Web 应用程序放入 301 重定向,该应用程序曾经位于子域上,但现在位于目录中,它也从 .asp tp .php 移动
基本重定向是
http://sub.domain.com/twforum/forum.asp?FORUM_ID=
重定向到
http://domain.com/forum/viewforum.php?f=
我可以做的这部分,但我不知道如何处理将在网址中传递的 id(论坛 id),我不希望论坛 id 被重写为url 友好打开,只是为了将其转移/重定向
我假设我需要 mod_rewrite 查询部分。
这就是我得到的,
RewriteEngine On
RewriteCond %{QUERY_STRING} ^http://sub.domain.com/twforum/forum.asp?FORUM_ID=1$ [NC]
RewriteRule http://domain.com/forum/viewforum.php\?f=1$ [L,R=301]
任何人都可以看到那里有任何明显的错误或知道更好的方法吗?
谢谢
Iv seen load of htaccess examples and generators to rewrite a url, however I need to put in a 301 redirect for a web app which used to be on a subdomain, but is now in a directory, its also moved from .asp tp .php
the basic redirect is
http://sub.domain.com/twforum/forum.asp?FORUM_ID=
redirects to
http://domain.com/forum/viewforum.php?f=
this part i can do, but i dont know how to handle the id (forum id) that will be passed in the url, I DONT want the forum id to be rewritten to a url friendly on, just for it to be carried over/redirected
I assume i need to mod_rewrite the query part.
heres what iv got
RewriteEngine On
RewriteCond %{QUERY_STRING} ^http://sub.domain.com/twforum/forum.asp?FORUM_ID=1$ [NC]
RewriteRule http://domain.com/forum/viewforum.php\?f=1$ [L,R=301]
can anyone see any clear errors there or know of a better way?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
%{QUERY_STRING}
不包含整个网址。只是查询设置部分。例如FORUM_ID=1
假设您的论坛 ID 只是数字。
%{QUERY_STRING}
does not contain the whole of the URL. Just the query setting part. e.g.FORUM_ID=1
Assuming that your fourum ids re just numerals.