我更改了网址,需要为以下
设置r = 301/folder-path-old/file-name-old.html到/folder-path-new/file-name-new.html /folder-path-old/file-name-old/product-no-change.html to /folder-path-new/file-name-new/product-no-change.html
我猜第二个可以使用某种通配符,因为新路径中的文件没有改变......有什么想法吗?
到目前为止我尝试了什么:
RewriteRule /bean-bags/category-bean-bags.html /bean-bags/category.html [L,R=301]
RewriteRule ^/bean-bags/category-bean-bags/(.*)$ /bean-bags/category/$1 [R]
答案 0 :(得分:1)
删除前导斜杠:
RewriteRule ^bean-bags/category-bean-bags/(.*)$ /bean-bags/category/$1? [R,L]
.htaccess
是每个目录指令,Apache从RewriteRule
URI模式中剥离当前目录路径(从而导致斜杠)。答案 1 :(得分:0)
您可以改为使用mod_alias:
Redirect 301 /bean-bags/category-bean-bags.html /bean-bags/category.html
Redirect 301 /bean-bags/category-bean-bags/ /bean-bags/category/