简体   繁体   中英

Rewrite Rule with mod rewrite

I have recently migrated a asp.net website to php. I want to redirect the old URLs to the new URLs. 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)

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).

Again, jid=1 is always 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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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