Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I used webfonts in my Wordpress site. I need a rewriterule in my htacces. I put this in my htacces file:

RewriteRule ^fonts/(.*) /mikevierwind/wp-content/themes/roots/fonts/$1 [QSA,L]

But when i save this htacces file. Wordpress is rewriting the htacces file and my fonts rewriterule is gone. How can i fix that?

Thank for helping!

share|improve this question
    
Where in your .htaccess file are you adding that? –  hampusn Sep 19 '12 at 9:29
add comment

2 Answers

Please change the permissions of .htaccess to read-only by accessing it via SFTP, SSH, cPanel 'File Manager' or whatever the tool you have.

share|improve this answer
    
If you do that, WordPress will have problems with the Rewrite API and every plugin using it. WordPress needs to be able to write to the .htaccess file. –  hampusn Sep 19 '12 at 9:23
    
@hampusn I have yet to see a case where you need a rewritten .htaccess. –  toscho Sep 19 '12 at 9:41
    
@toscho Even so, is that really a reason to discard it? Just because you doesn't use a function at this point in time, there's no telling what will happen in a week, a month or a year. Imagine the hassle not using __(), _e(), _ex() etc. when you later realize you need another language for the site. Mike should at least be aware of the possible problems. –  hampusn Sep 19 '12 at 10:03
    
You can add new permalinks for endpoints, custom post types, rewrite tags … without touching the .htaccess. The hard rewrite is needed only if you don’t use the rewrite API. –  toscho Sep 19 '12 at 10:06
add comment

Add the rule outside of the WordPress block.

<IfModule mod_rewrite.c>
  # ...
  RewriteRule ^fonts/(.*) /mikevierwind/wp-content/themes/roots/fonts/$1 [QSA,L]
  # ...
<IfModule mod_rewrite.c>


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

You should also consider using the Rewrite API to do this. And read this text about debugging the .htaccess file.

Edit: This topic on stackoverflow.com could also be of use.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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