.htaccess重写不起作用

时间:2012-12-22 14:28:23

标签: wordpress .htaccess url-rewriting

因为我正在开发一个Roots& amp; Wordpress,Roots会将wp-content/themes/themename/assets/etc重写为assets/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

我觉得好吗?但它不起作用,这是我的服务器或文件本身的问题吗?

1 个答案:

答案 0 :(得分: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>