将大写 URL 重定向到特定于子文件夹的小写版本
Redirect uppercase URL's to lowercase version specific to a subfolder
我试过使用 mod_spelling 但 运行 遇到问题,我希望通过使用 htaccess 来实现。与此类似(取自 this post)(但是这会小写我假设的所有 URL)
RewriteEngine On
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] %1 [R=301,L]
我需要在特定的子文件夹中进行此操作,此子文件夹中的任何内容都应为小写版本 301
例如
www.example.com/subfolder/This-Would/Need2-to_Be-Lower
www.example.com/subfolder/another-Example/Be-Lower/Please_33
在“子文件夹”之后,如果有数字,它的深度应该无关紧要and/or
这是一个 joomla 网站,如果有帮助的话
在此感谢任何见解
您只能将此规则用于子文件夹:
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule ^subfolder/[^A-Z]*[A-Z] %1 [R=301,L,NE]
此处的模式 ^subfolder/[^A-Z]*[A-Z]
将匹配以 /subfolder/
开头且某处至少有一个大写字母的 URI。
我试过使用 mod_spelling 但 运行 遇到问题,我希望通过使用 htaccess 来实现。与此类似(取自 this post)(但是这会小写我假设的所有 URL)
RewriteEngine On
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] %1 [R=301,L]
我需要在特定的子文件夹中进行此操作,此子文件夹中的任何内容都应为小写版本 301
例如
www.example.com/subfolder/This-Would/Need2-to_Be-Lower
www.example.com/subfolder/another-Example/Be-Lower/Please_33
在“子文件夹”之后,如果有数字,它的深度应该无关紧要and/or
这是一个 joomla 网站,如果有帮助的话
在此感谢任何见解
您只能将此规则用于子文件夹:
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule ^subfolder/[^A-Z]*[A-Z] %1 [R=301,L,NE]
此处的模式 ^subfolder/[^A-Z]*[A-Z]
将匹配以 /subfolder/
开头且某处至少有一个大写字母的 URI。