3

当我正在使用 Roots 和 Wordpress 开发网站时,Roots 会重写wp-content/themes/themename/assets/etcassets/etc它不起作用。.htaccess 在底部包含这个:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^assets/css/(.*) /wp-content/themes/retlehs-roots-e3f7365/assets/css/$1 [QSA,L]
RewriteRule ^assets/js/(.*) /wp-content/themes/retlehs-roots-e3f7365/assets/js/$1 [QSA,L]
RewriteRule ^assets/img/(.*) /wp-content/themes/retlehs-roots-e3f7365/assets/img/$1 [QSA,L]
RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

对我来说看起来不错?但它不起作用,这是我的服务器或文件本身的问题吗?

4

1 回答 1

2

查看评论,您似乎将 WP 安装在子文件夹中。如果是这样,RewriteBase 应该反映这一点。

所以应该是RewriteBase /subfolder。另外,您应该删除/前面的/wp-content...

所以大家一起:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder
RewriteRule ^index\.php$ - [L]
RewriteRule ^assets/css/(.*) wp-content/themes/retlehs-roots-e3f7365/assets/css/$1 [QSA,L]
RewriteRule ^assets/js/(.*) wp-content/themes/retlehs-roots-e3f7365/assets/js/$1 [QSA,L]
RewriteRule ^assets/img/(.*) wp-content/themes/retlehs-roots-e3f7365/assets/img/$1 [QSA,L]
RewriteRule ^plugins/(.*) wp-content/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
于 2012-12-22T21:03:36.283 回答