简体   繁体   English

为什么此mod_rewrite规则不起作用(通过.htaccess将一个特定的网址访问另一个)

[英]Why won't this mod_rewrite rule work (via .htaccess one specific url to another)

RewriteRule ^ / tag / term $ / tag / term-expanded-here [R]

If you're using mod_rewrite in a .htaccess file , you need to remove the path prefix from the pattern: 如果在.htaccess文件中使用mod_rewrite ,则需要从模式中删除路径前缀:

When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the pattern matching and automatically added after the substitution has been done. 在.htaccess文件中使用重写引擎时,会自动删除每个目录的前缀(特定目录的前缀始终相同)以进行模式匹配,并在替换完成后自动添加

In case of the .htaccess file in the document root directory it's the leading / : 在文档根目录下的.htaccess文件的情况下,它的领先/

RewriteRule ^tag/term$ /tag/term-expanded-here [R]

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

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