My .htaccess file for WordPress keeps adding code to look like this:
# 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
AME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I don't need any code after the first "# END WordPress"
I don't know what is changing it and I just updated WordPress to version 3.5 to try and fix the issue but it is still there :/ Anybody have this issue or know how to fix it?
2/5/2013 EDIT: I updated WordPress, my Theme (AIT's Guesthouse), and WPML plugins and the issue seems to have disappeared. I'm still not sure which thing was causing it.
If anyone is still searching for this answer I had to do some research recently to solve the problem myself.
As it turns out WordPress can update your .htaccess whenever you modify your permalinks. I was experiencing the issue however based on a few stray plug-ins I attempted to update. I set the .htaccess file the way I wanted it and blocked any changes to the file by setting permissions to 644. You can also do 444 if that isn't strict enough for you. I do SSH but Filezilla or a similar FTP/SFTP program will work.
Also as a tip for the proactive, try maintaining your site with version control (I use Git through BitBucket) and you can have logs that will tell you when and what WordPress changes. Incredibly useful!
Related
I’ve changed my custom permalink setting to /%pagename%/ (which is common, I guess). However, the following problem keeps occurring:
When trying to open a post on my website, I receive a 404 error. When changing the permalink setting back to Standard, the errors disappear.
After googling, I found that there is a way to solve this by editing your .htaccess file. Even after this, the same problem reoccurs. As I would like to have clean page-names, would anyone know how to solve this problem?
Greetings,
Tom
Kindly delete your .htaccess file from the root folder and check your site again, if the problem is still there than regenerate the permalinks using %postname%.
For the url rewriting WP feature to work, WP writes the .htaccess file at the root of your WP installation.
Open the .htaccess file and check whether or not you have this piece of code:
# 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
If it is missing, you have 2 options:
change the file permissions so that WP can write it.
or add the missing code yourself to the .htaccess.
I am using wordpress on godaddy windows hosting. using 4,7,4 version of wordpress.
For some reason permalinks do not work in any mode except of plain, selecting any other structure results in 404 errors at all pages except of home. I know there is a ton of similar questions, but none of the existing solutions does not help (at least all solutions I could find).
.htaccess file is changing when permalink structure is modified, it adds a code that looks as it supposed to be:
# 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
Giving different permissions doesn’t do anything.
According to the hosting provider the web server meets all requirements
The website is using woocommerce. Disabling all plugins was tried as well – no effect.
Any other ideas how can I fix this or at least where the problem is? Thanks in advance
You may need to enable mod_rewrite to accept the server to access the formatted URL's
Edit , httpd.conf
AllowOverride all
Also inside php.ini remove ; from the below extension,
extension=php_curl.dll
I installed a clean version of the latest wordpress and set up a vhost for it correctly.
Everything works fine. The thing is when i am on the login form and i am trying to login to my backend i am getting the error. "Too many redirects" and i can't seem to fix it.
Does anyone here facing the same problem and can help me to fix it?
What i tried so far is that i reinstalled everything, but that doesnt fix the problem either. then i created a new user and tried with that one, still the same prob.
Anyone having an idea?
Step 1: Access the file wp-config.php and add the following.
define('WP_HOME','http://yourdomain.com');
define('WP_SITEURL','http://yourdomain.com');
Replace yourdomain.com with the your website URL.
Step 2: Delete your current .htaccess file and create a new .htaccess file with the following contents.
# 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
This could resolve the issue.
I have a website made with wordpress 4.2.2. Sometimes my .htaccess is erase by an older version, which look like that.
# 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
I've added many PermanentRedirect under the "RewriteRule . /index.php [L]" line. Only these lines desappears.
I already looked here and there
None of the plugins interract with the .htaccess and it's not he whole content that disappear.
I don't have any clue of what could be the origin of this issue.
EDIT: It seems that every time someone access the permalink setting page, the .htaccess is erase.
WordPress considers anything between the # BEGIN WordPress and # END WordPress to be its "territory". It uses those comments to find and replace its own rules when updates are necessary.
If you want to add custom rules, you must add them outside that block so WordPress does not overwrite them.
Sorry for the lack of update.
Still don't know how my code got overwritten previously, but putting my rules outside # BEGIN WordPress and # END WordPress comment-line did the trick.
I am having a CRAZY error with Wordpress. When I create a new article or edit an old one, I cannot insert hotfile links that go after the first trailing slash.
I'm explaining it better. If in a post I do:
TEST
I can correctly create the article. If I do:
TEST
Or longer link, like:
TEST
I get an instant 403 error when updating the post from administration. This is crazy, and happens only with Hotfile links. Everything else works like a charm.
What could the error be? If it helps, i'm posting my .htaccess, that I never changed from my WP installation:
# 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
Already done repairing and optimization of MySQL DB. Kind thanks in advance to everyone.
I'm a regular WP developer, and I see little bugs like this all the time. Unfortunately, it usually means it's time to go through the tedious work of testing. The problem likely lies either with Apache/htaccess, or in a WP plugin or Theme.
To attempt to eliminate WP as the cause of this specific issue, I'd try creating a php file with the following in it:
<?
if (isset($_POST["field"]))
echo $_POST["field"];
?>
<form method='post'>
<input type='hidden' name='field' value='TEST'>
<input type='submit' value='Test'>
</form>
If clicking "Test" does not result in the same 403 error, then it's something happening with WP specifically. If it does result in a 403, then it's a much more annoying problem that you are going to want to take up with your hosting provider.
If it is a WP problem, the first thing I would do is to start deactivating plugins 1 by 1, starting with the plugins I think are the most likely culprits. If I have no reason to suspect one over another, I just disabled them all, 1 at a time. Once a plugin is disabled, I try to recreate the original issue. If the problem still happens, it's obvious that plugin wasn't at fault, and I reactivate it and test the next one. 9 times out of 10, my issue is found this way. Be careful when trying this, as some plugins will clear their settings when they're deactivated.
If that doesn't solve the issue, I'll try a different theme and see if that fixes it. Obviously if the problem is gone when you try a new theme, you know where your problem is. Again, some themes can have setting associated with them, and changing the theme can lose those settings.
Finally, check your wp-content/mu-plugins folder for plugins that are always active and don't always show up in your list of plugins.
I realize this post is as ancient as time itself but I've run into a similar problem took me forever to figure out what was going on until i realized all I had to do is add:
Options +FollowSymLinks
At the top of the .htaccess file and presto! It worked.
Options +FollowSymLinks
# 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
Credit goes to this good man: http://www.coolestguyplanettech.com/403-forbidden-error-wordpress-htaccess/
I also had a similar issue, apparently wordpress has some problems with some bits of code I tried to add in my post. I managed to bypass the issue by surrounding the code in <pre> tags.
Mostly, 403 forbidden error is because of four reasons 1. File permission. 2. Issue with plugins. 3. Hotlink protection 4. issue with .htaccess file 5. Your CDN(Content Delivery Network). For solving this error you need to check all these aspects to remove the error.
check the file permission as you know
the file has permission for 644 and the directory 755
Deactivate the plugins. Sometimes you might get errors because of plugins
next you need to delete .htaccess file and create a new file with the below code
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Next you need to check hotlink protection for your site. As it proved your website to link media or files from other sites.
lastly, you need to check for CDN you can disable it to know if it causing error or not.
I know my answer is late in coming but just wanted to add my 2 cents.
I would recommend checking the .htaccess file to make sure it is similar to below.
# 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 could try adding Options +FollowSymLinks as adamj stated in his answer so the .htaccess would look similar to below.
Options +FollowSymLinks
# 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
Check to ensure that no plugin are causing the issue. Disable all plugins to see if the issue persist. If it doesnt, it would be a process of elimination to figure out which one is the cause.
Finally, I have removed the .htaccess file and that also worked for me but no .htaccess file would means no URL rewrite unless your web server is otherwise configured.
I hope this helps someone.