Wordpress Load - Issue with Rewrite rules? - wordpress

I have begun to have some issues over the past week with the site not loading or not loading properly (mainly in Chrome and Firefox), as well as a time when the permalink structure reset to the WordPress default, and a couple of times when I've been logged out of the WordPress back-end when making edits.
My web host said that it it was most likely an error with a mis-configured re-write rule in the .htaccess file. I can't see anything wrong (but am not sure whether I would know if I saw it...)
The only times I find rewrite mentioned in htaccess are pasted below.
Do you think this is what the problem is, or something else?
Thanks
# BEGIN W3TC Skip 404 error handling by WordPress for static files
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(robots\.txt|sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?)
RewriteCond %{REQUEST_FILENAME} \.(css|js|htc|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ [NC]
RewriteRule .* - [L]
</IfModule>
# END W3TC Skip 404 error handling by WordPress for static files
# 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

The admin url for wordpress isn't based on Rewrite rules. If you're being randomly logged out while making edits either the session has been removed or has timed out.
As for permalink structure resetting, it would likely be one of:
You or someone else with admin access has told wordpress to do so (intentionally or otherwise
The .htaccess file in your base wordpress folder has been deleted
The apache conf has been modified to ignore local htaccess / mod_rewrite rules
I'm not entirely sure what you mean by not loading properly, but if it were a htaccess problem I would think it would either work, or it wouldn't. Nothing in between.

I have begun to have some issues over the past week with the site not
loading or not loading properly (mainly in Chrome and Firefox), as
well as a time when the permalink structure reset to the WordPress
default, and a couple of times when I've been logged out of the
WordPress back-end when making edits.
This sounds like a session timeout/cookie problem, and very unlikely related to your .htaccess rules.
In addition to firewall/proxies that may be in the middle of your browser and the server, such things can be caused by clock skews; try checking the time on your server and on your computer.

[1]Clear you web cache.
If that doesn't help:
[2]Reset the htaccess file for your site. Reset the permalink settings.
If that doesn't help:
[3]Have you updated any plugins lately? Think about any changes that have been made recently to the backend of the site.
Hope this gives you some ideas.

Related

Unable to change Permalink - Tried tons of tricks

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

apache htaccess mod_rewrite to check cache folder first then run WordPress index.php

I am setting up a very simple cache for my own WordPress plugin... I have been researching this here on StackOverflow and elsewhere for a couple of days. Found some great answers that were very close (looking for image files, etc), but none for this specific scenario - and modifying other solutions is not working.
I've got everything working except the rewrite rules to do the following:
Incoming request for either http / https
domain.com/page-slug/ OR domain.com/year/month/page-slug/
Need htaccess to first check the cache folder for
domain.com/wp-content/cache/myfolder/page-slug.html
(please note the incoming request can be for "/page-slug/" OR "/page-slug" and the cache file name has the ".html" extension to make it "page-slug.html")
If the cache file does not exist, then just
...go through the usual WordPress index.php process
Also -- what if there is no slug/page name in the url?
ie: the home page ... can htaccess direct
domain.com to domain.com/wp-content/cache/myfolder/index.html
and if the cached index.html does not exist, go to the WP index.php
Is there a way to do the above cache checks purely with the .htaccess rules? Any guidance would be greatly appreciated.
( I hope my explanation above was clear -- I get confused myself! LOL )
UPDATE:
I found a good answer in htaccess rewrite if file not exists in cache folder by anubhava and tried to modify it as follows, I think it is close, but its not quite working:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# Admin area
RewriteRule ^admin(.*) admin$1 [L]
# Check if file *.* exist in the cache foldel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/cache/ebg/$1 -f [NC]
RewriteRule ^(.+?)/?$ /cache/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If the above solutions don't work, please contact your web host provider. Most likely you don't have Mod_Rewrite activated on your webhost package.

Setting .htaccess for Wordpress in a subdirectory with 'Post name' permalinks

I am trying to set up a Wordpress installation, where Wordpress is in a subdirectory, but where the subdirectory is always rewritten out of the URL.
I've been trying to follow a whole bunch of other questions / posts about doing this, but no one else's solutions seem to work for me, and a lot of the time they just get the pages to load, without removing the subdirectory from the URL, which is crucial for me.
I'm also hoping for a solution that will work the same locally (http://localhost/wordpress) as it will on a live server (http://example-site.com). However, I'll explain the problem from a local point of view:
My root folder is structured like this:
.htaccess
wp /* contains all wordpress core files */
wp-content /* custom wp-content folder, which is set to be pointed at in my wp-config */
wp-config.php
So, if we ignore the .htaccess, the site would be accessed by going to http://localhost/wordpress/wp, and the goal is to access it by just going to http://localhost/wordpress.
This was achieved using this .htaccess:
RedirectMatch 302 /wp/$ /wordpress/$1
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ wp/$1
RewriteRule ^(/)?$ wp/index.php [L]
</IfModule>
However, at this point, my wordpress installation was set to use default permalinks, which create pages like http://localhost/wordpress?p=12. I need to set this to a different permalink type, which uses URL segments rather than query parameters, like http://localhost/wordpress/hello-world. Once that setting is changed, I can no longer access other pages with that .htaccess (the home page still works fine though)
I tried using this .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/wp/$1 [L]
</IfModule>
Which now causes the sub pages to load, though the home page no longer does, nor do some asset files, like http://localhost/wordpress/wp-includes/css/admin-bar.min.css
I can't seem to find a solution that makes everything work at the same time!
I'd also like to mention that I have a very small understanding of writing .htaccess files, so if anyone is going to answer this, please explain things like I am an idiot, as I may not understand you otherwise.
I am considering that you have redirected the domain to the relavant folder, or on shared hosting you have setup the domain to point to your subfolder. I am also considering that you are adding the htaccess to the root. Here is code from the official codex for your situation.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ blog [L]
Replace yourdomain.com and blog with website address and directory. Delete everything else from the file. Then goto settings > permalink and change the permalink to what ever you want.

Wordpress htaccess not a directory rule keep firing anyway

I have a strange problem with a site i installed on my server, the same exact code works elsewhere so i'm stuck here trying to figure out what is not working.
# 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 is the standard Wordpress htaccess. Technically, the "!-d" rule should allow me to list or access any directory but in this install, it's not the case.
I have a "admin" folder and wordpress keeps kicking in and handling the admin url as "wp-admin" but thats not what i want. I already have other servers where i have a custom "admin" folder mixed with wordpress and it launches fine but something strange here seems to be hapenning.
What we have done:
Disable the rewrite engine, wordpress turns off the folder responds
Disable/Reenable the rewrite engine (to flush possible existing rules) nope
Tried to add "RewriteCond %{REQUEST_URI} !^/admin", doesn't work, WP still kicks in
Can you guys suggest anything else?
After some testing we found out that wordpress was catching all error messages even the 401 on our server. It kept showing 404 because thats the only rendered error by Wordpress.
To this end, we just put a
RewriteEngine Off
In the folder we were trying to access and blam! all of it works now!
I hope this can help others!

Problem with htaccess file. Wordpress Plugin tells me there is one, I can't find one?

i have an really unusual problem i've never had before.
i've no .htaccess file on my server. looked everywhere, there is just no file, but a Wordpress Plugin (AskApacheRewriteRules) tells me that the following Rules are active:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
any idea why that could be, i've already wrote my hosting provider, but their service isn't the best.
even if i create an htaccess file with other rules and save it to my root of the server, it doesn't change anything. The plugin always tells me the same and i believe the plugin, because i'm having issues with the /index.php/ in my url (that i don't want to have).
any ideas?
On the AskApacheRewriteRules options page, did you make sure that using_index_permalinks is set to false and that using_mod_rewrite_permalinks is set to true? If this isn't the case, WordPress will attempt to use PATH_INFO for your permalinks, resulting in /index.php/(permalink_structure).
Note that the WordPress rewrite class stores its rewrite rules as a WordPress option in the database, which is where AskApacheRewriteRules gets its information. The plugin also apparently formats the rules with the mod_rewrite_rules function before echoing them to the page, which will surround them with:
<IfModule mod_rewrite.c>
...
</IfModule>
So, the likely reason you can't find the .htaccess file is because it doesn't exist; the rules are just present in the database. The reason why the rules are present in the database is because you're using permalinks, and this is the auto-generated WordPress ruleset, which is saved regardless of whether it's actually being used or not.
Edit: You must have a .htaccess file in the root of your web directory with the following contents:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If mod_rewrite isn't available, we'll do this a hackish (and bad) way...
ErrorDocument 404 /index.php
</IfModule>
The rewrite_rules option is stored at SELECT option_value FROM wp_options WHERE option_name = 'rewrite_rules', but it gets regenerated every time you change the permalink, and isn't used except for writing to .htaccess from what I can tell.
Anyway, those are definitely the correct rules for what you want to do. Are you sure that mod_rewrite is enabled on your host?
Edit:
Let's make 100% sure that mod_rewrite is working correctly and go from there.
Create a .htaccess file in your web root with the following rules, exactly as written:
RewriteEngine On
RewriteRule ^rwtest http://stackoverflow.com/ [R,L]
Then go to your site with the URL example.com/rwtest and see if you get redirected to StackOverflow. If not, something is wrong with mod_rewrite. If you do, then at least we know that piece isn't the problem.
Have you checked if it's defined in your apache configuration file (it appears that the plug is showing an excerpt from that).

Resources