这是我当前的.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]
RewriteCond %{REQUEST_URI} .*jpg$|.*gif$|.*png$|.*css$|.*js$ [NC]
RewriteRule (^.*) http://d14t2ycfqndlt4.cloudfront.net/$1 [R=301,
最后两行不起作用,当我删除上面的第一个cond时,id确实有效......
有什么问题?谢谢!
答案 0 :(得分:2)
这样的事情应该有效:
RewriteEngine On
RewriteCond %{REQUEST_URI} (.*)\.(jpg|gif|png|css|js)$ [NC]
RewriteRule (.*) http://d14t2ycfqndlt4.cloudfront.net/$1 [R=301,...]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule (.*) - [NC,L]
RewriteRule (.*) index.php [NC,L]
请注意,正则表达式更容易理解。
答案 1 :(得分:0)
这是您已更正并已清理的.htaccess
代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule \.(?:jpg|gif|png|css|js)$ http://d14t2ycfqndlt4.cloudfront.net%{REQUEST_URI} [R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]