简体   繁体   English

使用mod重写规则

[英]Rewrite Rule with mod rewrite

I have recently migrated a asp.net website to php. 我最近将asp.net网站迁移到了php。 I want to redirect the old URLs to the new URLs. 我想将旧的URL重定向到新的URL。 I need help in redirecting the following: 我需要重定向以下内容的帮助:

ex1: /journals.aspx?href=issue&jid=1&id=16 to /jor/issue/16 (if href=issue then jid 1 is always jor in the new website and id parameter 16 is the issue) 例1: /journals.aspx? href = issue&jid = 1&id = 16/ jor / issue / 16 (如果href = issue,则jid 1在新网站中始终是jor,而id 参数 16是问题)

ex2: /journals.aspx?id=118&jid=1&href=abstract to /jor/Article/118 (if href=abstract then it will redirect to article with article id that equals id). 例2: /journals.aspx? id = 118jid = 1&href =抽象到/ jor / Article / 118 (如果href = abstract则它将重定向到商品ID等于ID的商品)。

Again, jid=1 is always jor. 同样,jid = 1总是jor。

Thanks! 谢谢!

These rules should do it 这些规则应该做到

RewriteEngine on

# Match issue
RewriteCond %{QUERY_STRING} href=issue 
RewriteCond %{QUERY_STRING} jid=1
RewriteCond %{QUERY_STRING} (^|&)id=([0-9]+)
RewriteRule journals.aspx /jor/issue/%2? [R]

# Match abstract
RewriteCond %{QUERY_STRING} href=abstract 
RewriteCond %{QUERY_STRING} jid=1
RewriteCond %{QUERY_STRING} (^|&)id=([0-9]+)
RewriteRule journals.aspx /jor/Article/%2? [R]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM