Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess rewrite isn't working

As I'm developing a site with Roots & Wordpress, Roots will rewrite wp-content/themes/themename/assets/etc to assets/etcbut it's not working. .htaccess contains this on the bottom:

# 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

It looks fine to me? But it's not working, so is this a problem with my server or the file itself?


1 Answers

Looking at the comments it seems you installed WP in a subfolder. If so the RewriteBase should reflect this.

So it should be RewriteBase /subfolder. Also you should remove the / in front of /wp-content...

So all together:

<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>
like image 90
Gerben Avatar answered Feb 07 '26 01:02

Gerben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!