我正在尝试将旧图像路径重新映射到使用Codeigniter构建的网站上的旧图像路径。
旧路径如下所示:
mydomain.com/images/maps/MI/206717178X.jpg
并且新路径如下所示:
mydomain.com/resources/images/products/front/MI/206717178X.jpg
这是我的.htaccess文件:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^images/maps/([A-Z]{2,3})/(.*)$ resources/images/products/front/$1/$2 [L]
RewriteRule .* index.php/$0 [PT,L]
我得到了Internal Server Error: The server encountered an internal error or misconfiguration and was unable to complete your request.
如果我删除最后一行,重映射效果很好,但当然整个网站都不起作用,因为它需要所有网址中的index.php ......
所以最后一行和重映射行之间似乎存在冲突,但我不知道它是什么。任何指针都将受到高度赞赏!
答案 0 :(得分:1)
RewriteCond
仅适用于下一个RewriteRule
。试试这段代码:
RewriteEngine on
# skip files/directories from all the rules below
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^images/maps/([A-Z]{2,3})/(.*)$ resources/images/products/front/$1/$2 [L]
RewriteRule ^ index.php/$0 [L]