.htaccess help needed for redirects

扶醉桌前 提交于 2020-02-06 05:00:40

问题


How can I redirect both these URL's back to /blog/ and covering any variations that also include ?page_id for the first one and no_redirect for the second one.

  • https://www.example.com/blog/page/10/?page_id=%2Ffeed%2Fatom%2F

and

  • https://www.example.com/blog/page/10/?no_redirect=true

Appreciate the help!


回答1:


Try :

RewriteEngine on

RewriteCond %{THE_REQUEST} /blog/page/10/\?page_id=%2Ffeed%2Fatom%2F [NC,OR]

RewriteCond %{THE_REQUEST} /blog/page/10/\?no_redirect=true [NC]
RewriteRule ^ /blog/? [L,R]

EDIT :

here is an another way to redirect everything after the /blog/page/* to /blog/

RewriteEngine on
RewriteCond %{THE_REQUEST} /blog/page/ [NC]
RewriteRule ^ /blog/? [L,R]


来源:https://stackoverflow.com/questions/36484786/htaccess-help-needed-for-redirects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!