我们在Ubuntu上安装了WP博客
/home/himalayan/public_html/blog/index.php
该博客有一个“品牌名称”又名TAKA
https://www.himalayanacademy.com/blog/taka # this URL works
但这失败了:
https://www.himalayanacademy.com/taka
即使我们有这些规则
RewriteRule ^taka/?$ /blog/taka [R]
RewriteRule ^taka?$ /blog/taka [R]
RewriteRule taka /blog/taka
我们正在使用Cloud Flare,但博客没有缓存...但作为测试,我使用完全限定的网址
RewriteRule ^taka/?$ https://www.himalayanacademy.com/blog/taka [R]
RewriteRule ^taka?$ https://www.himalayanacademy.com/blog/taka [R]
RewriteRule taka https://www.himalayanacademy.com/blog/taka [R]
但没有人有效......
https://www.himalayanacademy.com/taka
总是挂着?任何线索
答案 0 :(得分:1)
您可以尝试使用目录重定向。例如,通过RedirectMatch
指令:
RedirectMatch 301 ^/taka/(.*) /blog/taka/$1
您的匹配正则表达式也是以t
而不是/
开头的,如果您将其更改为^/t
并添加"任何内容"最后(.*)
模式。例如:
RewriteEngine on
RewriteRule "^/taka/(.*)" "/blog/taka/$1" [L,R=301]
此外,您可以尝试使用简单的Redirect
指令(不需要正则表达式):
Redirect "/taka/" "/blog/taka/"
Apache httpd website中的更多解释和示例。