8 Replies - 3331 Views - Last Post: 10 February 2014 - 11:13 AM

#1 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

WP .htaccess file being overwritten

Posted 05 February 2014 - 06:22 AM

Hello fellow programmers, I haven't been on in awhile but have come to a snag in the road and would like a opinion or thoughts towards a fix.

I have added my own rules to the .htaccess file on a WordPress website.
It handles a splash page/landing page system that uses a template.

So if a request is made for something in this format
http://example.com/lp/page.php

It will pull the "page" (what is between the final / and .php, search the database and load the template

But when WordPress goes through a update it clears my rules with the default WordPress rules.

I have Google'd and all I have found are 6+ years of old answers and the answers make sense - but don't seem to be the fix.
People have said, "If you keep your code outside of the wordpress chunk, it should be fine"

WordPress block is like so
# 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


My rules are above the block, yet still get erased.

So I was thinking, would adding another .htaccess file inside of the physical /lp/ folder be a fix?
Because wordpress checks if file & directory exist.

Any thoughts comrads?

This post has been edited by Dormilich: 05 February 2014 - 06:41 AM


Is This A Good Question/Topic? 0
  • +

Replies To: WP .htaccess file being overwritten

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,052
  • Joined: 08-June 10

Re: WP .htaccess file being overwritten

Posted 05 February 2014 - 06:41 AM

Quote

But when WordPress goes through a update it clears my rules with the default WordPress rules.

thats what an update is supposed to do (although "replace" would be the more correct term here)


Quote

So I was thinking, would adding another .htaccess file inside of the physical /lp/ folder be a fix?
Because wordpress checks if file & directory exist.

Id put it in the top directory (web root for your page). if that is outside WPs reach.

otherwise, make a backup and restore the missing section after each update.
Was This Post Helpful? 0
  • +
  • -

#3 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: WP .htaccess file being overwritten

Posted 05 February 2014 - 06:57 AM

Replace, clear, to-may-to to-mah-to lol

Wordpress is in the root directory, for the last few years I have just uploaded the backup.
Maybe I can rewrite the Wordpress function to include my rules in with the updates
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,205
  • Joined: 15-January 14

Re: WP .htaccess file being overwritten

Posted 05 February 2014 - 09:29 AM

If the .htaccess file is actually being overwritten with a new file then obviously that's going to clear out your data. If you're uploading the new files then make sure you aren't uploading the .htaccess file.
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,890
  • Joined: 10-May 07

Re: WP .htaccess file being overwritten

Posted 05 February 2014 - 12:33 PM

Administration of the .htaccess file is web hosting issue, & is not related to the php language. Topic moved to Web Hosting & Servers.
Was This Post Helpful? 0
  • +
  • -

#6 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: WP .htaccess file being overwritten

Posted 06 February 2014 - 06:10 AM

Thanks for moving it no2pencil

I think wordpress is doing it automatically when it goes to upgrade to newest version.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,890
  • Joined: 10-May 07

Re: WP .htaccess file being overwritten

Posted 06 February 2014 - 06:38 AM

Wordpress overwrites the .htaccess file anytime that you make changes that will require it to do so. Permalinks for example. If you dont' wish for the file to be over-written, you can always change the permissions of the file. Wordpress will show an error when it is unable to overwrite the file.
Was This Post Helpful? 0
  • +
  • -

#8 RWenger  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-January 12

Re: WP .htaccess file being overwritten

Posted 10 February 2014 - 12:53 AM

This plugin looks like it would allow you to make your changes persistent.

http://wordpress.org...taccess-editor/

Ah right, can't edit yet. I meant to link this plugin: http://wordpress.org...access-control/
Was This Post Helpful? 0
  • +
  • -

#9 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: WP .htaccess file being overwritten

Posted 10 February 2014 - 11:13 AM

Thank you for the suggestions, I will look into them out of curiosity.

In the mean time, I wrote some software monitor the remote files for me and upload if anything has changed.

Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1