我有一部分网址要替换为htaccess:
如何将root/aaa/bbb/css/images/ddd.image.png
替换为root/aaa/css/images/ddd.image.png
我在根文件夹中的.htaccess中尝试了这段代码:
RewriteEngine On
RewriteRule ^aaa/bbb/(.*) /aaa/$1 [L,QSA,R=301]
在aaa文件夹中,有.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
答案 0 :(得分:1)
您需要在/aaa/.htaccess
中使用此规则:
RewriteEngine On
RewriteBase /aaa/
RewriteRule ^bbb/(.+)$ $1 [L,NC,R=301,NE]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.php [L]