简体   繁体   English

RewriteRule 的 mod_rewrite 问题

[英]mod_rewrite issues with RewriteRule

Can this rule be modified:是否可以修改此规则:

RewriteRule ^/it(.*)$ /information-technology$1 [R=301,NC,L,QSA]

to handle all scenarios below?处理下面的所有场景? (As-is above does not work for those marked ERROR ) (原样不适用于标记为ERROR 的那些)

  • /it
  • /IT
  • /it/
  • /IT/ (ERROR - does not redirect) /IT/ (错误 - 不重定向)

-- ——

  • /it/team/ redirects to /information-technology/team/ /it/team/重定向到/information-technology/team/
  • /it/team (ERROR - does not redirect) /it/team (错误 - 不重定向)
  • /IT/team redirects to /information-technology/ (ERROR) /IT/team重定向到/information-technology/ (错误)
  • /IT/team / redirects to /information-technology/ (ERROR) /IT/team / 重定向到/information-technology/ (错误)

-- ——

  • /italics redirects to /information-technology/alics (ERROR) /italics重定向到/information-technology/alics (错误)

-- ——

Thank you for your help in advance!!提前谢谢你的帮助!!

You may use this rule:你可以使用这个规则:

RewriteRule ^/?it(/.*)?$ /information-technology$1 [R=301,NC,NE,L]
  • Make sure this is top most rule in your site root .htaccess确保这是您站点根目录中最重要的规则 .htaccess
  • Make sure to test it in a new browser确保在新浏览器中测试

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

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