I've used some custom rewrites implemented by the Roots framework. Occasionally they get wiped: certainly if I visit Settings > Permalinks, but also at seemingly random times.

My htaccess reads so:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^css/(.*) /wp-content/themes/the-hit-centre/css/$1 [QSA,L]
RewriteRule ^js/(.*) /wp-content/themes/the-hit-centre/js/$1 [QSA,L]
RewriteRule ^img/(.*) /wp-content/themes/the-hit-centre/images/$1 [QSA,L]
RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]
RewriteRule ^media/(.*) /wp-content/uploads/$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I've tried removing the

# BEGIN WordPress

comments, but then WP just writes a new block of code.

Is there a hook I can call in functions.php that will prevent WP refreshing the permalinks?

thanks, Tim


There is a # BEGIN WordPress and # END WordPress after the end you should be able to add your own code. Anything between will get overwritten by WordPress

| improve this answer | |
  • example code here whypad.com/posts/… – Drai Mar 1 '12 at 22:50
  • Thanks Drai - I'll follow whypad's lead and double up on the <IfModule, RewriteEngine On business.. The other approach I considered was to set .htaccess as not writable... Thanks! – ptim Mar 2 '12 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.