我希望你们能帮我一把。我想重命名我的主题的CSS & JS路径,但我似乎无法弄清楚。例如:
我想要改变:
http://cdn.(domain-name).com/wp-content/themes/smart-mag/style.css
至
http://cdn.(domain-name).com/style.css
&来自:
http://cdn.(domain-name).com/wp-content/themes/smart-mag/js/bunyad-theme.js
至
http://cdn.(domain-name).com/js/bunyad-theme.js
等等
下面是我在我的.htaccess文件中尝试的内容:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-content/themes/smart-mag/screenshot\.png|readme\.html|license\.txt|wp-content/debug\.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteCond %{REQUEST_URI} \.(css|js|jpe?g|gif|png|bmp)$
RewriteCond %{REQUEST_URI} !^/themes/smart-mag/
RewriteRule ^(.*) /themes/smart-mag/$1 [L]
</IfModule>
#END WordPress 修改后的htaccess根本没有任何作用。我在这里错过了什么/做错了什么?
发布于 2014-09-16 23:16:16
你需要改变你的规则的顺序。wordpress规则将所有请求路由到index.php,包括您的/style.css等URL。所以你得先给他们安排路线。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.(css|js|jpe?g|gif|png|bmp)$
RewriteCond %{REQUEST_URI} !^/themes/smart-mag/
RewriteRule ^(.*) /themes/smart-mag/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-content/themes/smart-mag/screenshot\.png|readme\.html|license\.txt|wp-content/debug\.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
#END WordPress https://stackoverflow.com/questions/25879153
复制相似问题