Comments on: Stop WordPress Overwriting Custom .htaccess Rules http://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/ Search Engine Optimisation Ireland Tue, 31 Mar 2015 10:03:56 +0100 hourly 1 http://wordpress.org/?v=3.9.1 By: Leandrohttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-323099 Sat, 01 Dec 2012 07:31:24 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-323099 Thanks for this post, I had the same issue and was trying to figure out how to make wordpress don’t override my rules.

]]>
By: Tobias Beuvinghttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-137907 Sun, 22 Jul 2012 15:22:16 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-137907 Hi Richard,

I use a bunch of custom rewrite rules (I also use w3 total cache), everything worked fine uptill an update to wp 3.4 (or so).

After trying for days now, slightly desperate I applied your solution and now everything works again!

Funny since I am writing this in july 2012 and your post is from 2007 – worked for me!

Thanks a lot for sharing!

Kind regards,

Tobias Beuving

]]>
By: Johnhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-34158 Thu, 31 Mar 2011 11:34:31 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-34158 mmm, looks like all the opening & closing ifmodule tags have been removed from my previous post – not sure why that happened – anyway, i hope you get what i meant by all that.

]]>
By: Johnhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-34157 Thu, 31 Mar 2011 11:32:03 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-34157 Hi Richard – i have a problem with W3 Total Cache plugin – whenever i try to update Core WordPress version on my sites these rules always get overwritten – i’ve tried enclosing the W3 Total Cache rules in these tags:

RewriteEngine On
[... ]Funky custom rules go here[ ...]

However, whenever i go back into my wp-admin area to the w3 total cache settings im asked to reapply my cache settings and that reverts my htaccess file back the way it was – the only difference being that I have empty code at the top of the file – here’s what the file looks like now:

RewriteEngine On

# BEGIN W3TC Browser Cache

AddType text/html .html .htm
AddType text/richtext .rtf .rtx
AddType image/svg+xml .svg .svgz
AddType text/plain .txt
AddType text/xsd .xsd
AddType text/xsl .xsl
AddType text/xml .xml

ExpiresActive On
ExpiresByType text/html A3600
ExpiresByType text/richtext A3600
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
ExpiresByType text/xsd A3600
ExpiresByType text/xsl A3600
ExpiresByType text/xml A3600

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

Header append Vary User-Agent env=!dont-vary

AddOutputFilterByType DEFLATE text/css application/x-javascript text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon

FileETag None

Header set X-Powered-By “W3 Total Cache/0.9.1.3″

FileETag None

Header set X-Powered-By “W3 Total Cache/0.9.1.3″

FileETag None

Header set X-Powered-By “W3 Total Cache/0.9.1.3″

# END W3TC Browser Cache

# BEGIN W3TC Page Cache

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (2\.0\ mmp|240×320|alcatel|amoi|asus|au\-mic|audiovox|avantgo|benq|bird|blackberry|blazer|cdm|cellphone|danger|ddipocket|docomo|dopod|elaine/3\.0|ericsson|eudoraweb|fly|haier|hiptop|hp\.ipaq|htc|huawei|i\-mobile|iemobile|j\-phone|kddi|konka|kwc|kyocera/wx310k|lenovo|lg|lg/u990|lge\ vx|midp|midp\-2\.0|mmef20|mmp|mobilephone|mot\-v|motorola|netfront|newgen|newt|nintendo\ ds|nintendo\ wii|nitro|nokia|novarra|o2|openweb|opera\ mobi|opera\.mobi|palm|panasonic|pantech|pdxgw|pg|philips|phone|playstation\ portable|portalmmm|ppc|proxinet|psp|pt|qtek|sagem|samsung|sanyo|sch|sec|sendo|sgh|sharp|sharp\-tq\-gx10|small|smartphone|softbank|sonyericsson|sph|symbian|symbian\ os|symbianos|toshiba|treo|ts21i\-10|up\.browser|up\.link|uts|vertu|vodafone|wap|willcome|windows\ ce|windows\.ce|winwap|xda|zte) [NC]
RewriteRule .* – [E=W3TC_UA:_low]
RewriteCond %{HTTP_USER_AGENT} (acer\ s100|android|archos5|blackberry9500|blackberry9530|blackberry9550|cupcake|docomo\ ht\-03a|dream|htc\ hero|htc\ magic|htc_dream|htc_magic|incognito|ipad|iphone|ipod|lg\-gw620|liquid\ build|maemo|mot\-mb200|mot\-mb300|nexus\ one|opera\ mini|samsung\-s8000|series60.*webkit|series60/5\.0|sonyericssone10|sonyericssonu20|sonyericssonx10|t\-mobile\ mytouch\ 3g|t\-mobile\ opal|tattoo|webmate|webos) [NC]
RewriteRule .* – [E=W3TC_UA:_high]
RewriteCond %{HTTPS} =on
RewriteRule .* – [E=W3TC_SSL:_ssl]
RewriteCond %{SERVER_PORT} =443
RewriteRule .* – [E=W3TC_SSL:_ssl]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* – [E=W3TC_ENC:.gzip]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =””
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|wp-.*\.php) [NC,OR]
RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in) [NC]
RewriteCond “/home/w30oil/public_html/wp-content/w3tc/pgcache/$1/_index%{ENV:W3TC_UA}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}” -f
RewriteRule (.*) “/wp-content/w3tc/pgcache/$1/_index%{ENV:W3TC_UA}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}” [L]

# END W3TC Page Cache

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Appreciate any help you can give me to figure this out :-)

]]>
By: Lannyhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-26518 Fri, 10 Dec 2010 16:41:40 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-26518 Thanks! I appreciate your post -it’s great to find a solution to a problem immediately after it happens. :)

]]>
By: Danielhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-16207 Sun, 23 May 2010 14:33:36 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-16207 Thanks a lot Richard !! I will do it exactly like you ve said and will let you know , is there some other way to see if some of the plugins are updating my .htaccess ? search in plugin script code etc? i will disable them everytime i will see that the 505 server continues..
btw. I have made some investigations and have found that the URL from my error logs belongs to one very big forum in china dedicating a lot to the spamming and is hosted on the same hosting(bluehost)
hxxp://makemoney.vipearn.com/ have changed http to hxxp to not spam here.
It lets me think that if they share the same server they could also hack bluehost – not me.

]]>
By: Richard Hearnehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-16205 Sun, 23 May 2010 12:52:53 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-16205 Hi Daniel

Most likely an installed plugin is adding this. Since it only seems to happen every day or 2 it’s going to be hard to track down the culprit.
Best advice is to disable plugins in small batches and watch to see if the problem goes away. Once you’ve tracked down a batch that removes the issue then disable each of those one by one to see which is causing the problem.
If you know of any installed plguins that update .htaccess then try to disable those first to track down culprit.

Hope you fix the problem, rgds
Richard

]]>
By: Danielhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-16176 Sat, 22 May 2010 11:53:39 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-16176 Hello,
I see that here almost anybody knows something about htaccess file, Can somebody help me with .htaccess file issue?
I have a wordpress website with some plugins and another subdomains installations, almost everyday or second day I got a 505 internal server error , if I remove .htaccess file it works again until next day or next 2 days.

I noticed that everytime it happens .htaccess file changes from :

# BEGIN WordPress

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

# END WordPress

to

# BEGIN WordPress

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

# END WordPress
s

After the problem something adds “s” at the end of the .htaccess file .
I have no idea what can cause it , could you tell me where can i find the problem ? I have the last wordpress version , my Hosting company is Bluehost.com , i run on:

Linux
Architecture x86_64
MySQL version 5.1.46-log
Apache version 2.2.15
Kernel version 2.6.28-10.40.intel.E1000E.BHsmp
PHP version 5.2.13

Hope that somebody can help , I am not .htaccess expert at all
thanks Daniel

]]>
By: Travishttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-14111 Wed, 07 Apr 2010 00:29:26 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-14111 Great tip. You are correct, a simple comment in the default .htaccess file would have been useful. Thanks!

]]>
By: Nickhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-9546 Fri, 18 Dec 2009 16:05:05 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-9546 Hey, good tip. I was having the same problem. I just added my custom rules to the bottom. Everything has been fine since.

]]>
By: David Robertsonhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-9008 Fri, 04 Dec 2009 22:15:41 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-9008 Excellent. Thank you so much. And there was me thinking a plugin was at fault!

]]>
By: Kevinhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1733 Mon, 22 Jun 2009 15:33:47 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1733 Wow, thank you. This has been making me CRAZY!!!

]]>
By: geehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1734 Mon, 25 May 2009 18:46:23 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1734 Brilliant! Solved all my headaches! THANKS!

]]>
By: Phil Buckleyhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1732 Fri, 30 Jan 2009 00:43:33 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1732 Ahhhh, thank you for saving me the trouble of trudging through the code.

]]>
By: WordPress: Prevent WP from Overwriting Custom htaccess Rules | WhyPadhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1726 Fri, 12 Sep 2008 03:24:06 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1726 [...] Thanks to Richard at Red Cardinal for pointing out the very simple fix to this problem here. [...]

]]>
By: pkmkhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1729 Wed, 23 Jul 2008 21:11:58 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1729 thanks, it was getting silly this overwriting of my custom .htaccess ;]

]]>
By: markushttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1731 Sun, 06 Jul 2008 07:16:29 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1731 thanks richard! fixed my problem!

]]>
By: James Thttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1727 Fri, 04 Jul 2008 15:57:23 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1727 Thank you very much for this.

It happened a few weeks ago and I assumed it was a server oddity that reset the .htaccess file.

But today I found that saving any post/page caused the .htaccess to take out all my custom rules.

I came here and it fixed it. Like you, I thought it made sense to only have 1 if statement rather than 2.

Many thanks.

]]>
By: Richard Hearnehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1730 Tue, 03 Jun 2008 20:53:43 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1730 @Kenrick – simple answer to that is that WP cannot write to .htaccess if you chmod it. WP can actually write some useful stuff in there, and quite a few plugins use this functionality.

]]>
By: kenrickhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1728 Mon, 02 Jun 2008 16:29:38 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1728 um, how about you just chmod the .htaccess file to not be writable by the server? as in read only access?

]]>
By: David Meadehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1725 Thu, 28 Feb 2008 20:33:07 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1725 Thanks for checking, Richard.

I just last night got it to work. I’m actually not 100% sure what combination of things I was messing with finally got it to work. :-)

]]>
By: Richard Hearnehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1724 Thu, 28 Feb 2008 19:57:28 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1724 Hi David

Have to say I wouldn’t know where to start. You’re .htaccess is a little more exotic than most.

Rgds
Richard

]]>
By: David Meadehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1723 Wed, 20 Feb 2008 16:14:14 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1723 Hi Richard. I found this post thanks to a google search in hopes of fixing a wordpress/.htaccess issue I’m having. I wonder if you could shed some light on why my .htaccess file is preventing wordpress pingbacks from working.

After messing around with my .htaccess I actually got a pingback to work once … once . Something in here is breaking pingbacks.

Any insight you might have would be greatly appreciated.

My rewrite rules are:

# Use PHP5CGI as default
AddHandler fcgid-script .php
FCGIWrapper /usr/local/cpanel/cgi-sys/fcgiwrapper .php

RewriteEngine On
RewriteBase /
RewriteRule ^feed/?$ http://feeds.feedburner.com/DavidMeade [QSA,L]
RewriteRule ^itunes/?$ http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=87086557 [QSA,L]
RewriteRule ^media/(.+)/?$ /post/post.php?mediaID=$1 [QSA,L]

# BEGIN WordPress

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

# END WordPress

]]>
By: Stupendous Man » Separate Feedburner feeds and categories feeds using .htaccesshttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1722 Wed, 21 Nov 2007 04:20:18 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1722 [...] I stumbled upon this as I was doing a bit of research, and hit upon some excellent posts here and here. [Please do read those posts before going ahead as they are excellent source of information] I had [...]

]]>
By: Raymondhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1721 Sat, 25 Aug 2007 03:30:53 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1721 Hey thanks for the advice…I’ve been having trouble with that too…hopefully this will fix the problem!

]]>
By: Richard Hearnehttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1720 Tue, 12 Jun 2007 08:37:54 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1720 @John – I’m happy that I’m not the only one to have come acropper with this. So far it seems to be holding out well for me – only reason I’ve needed to update my .htaccess file as been to ad some new referrers to ban.

@ Paul – yep. Generally you wont need this.

Rgds to both!

]]>
By: paulhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1719 Tue, 12 Jun 2007 08:27:13 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1719 err in the brackets should be ‘<ifmodule mod_rewrite.c>’ :(

]]>
By: paulhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1718 Tue, 12 Jun 2007 08:25:51 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1718 hiya,
I do mine the same way, but one question the “” that you have ? Is this just to stop Apache crashing incase great sysadmin forgets to reinstall mod_rewrite ?
thanks,
paul

]]>
By: JLHhttp://www.redcardinal.ie/blogs/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1717 Mon, 11 Jun 2007 22:11:25 +0000 http://www.redcardinal.ie/webdev/11-06-2007/stop-wordpress-overwriting-htaccess/#comment-1717 Thanks Richard, I’m off to see if I’ve got anything within the wordpress block.

]]>