How to solve issues regarding custom 500 and 503 error pages - wordpress

My Website's
Header:
HTTP/1.1
Server:
Apache
CMS:
WordPress
In .htaccess file I'd the following:
# 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
Now, I've created a custompage.html page and kept it in the website's root (so that it can be accessed as mywebsite.com/custompage.html). Then I added the following code to .htaccess file:
# 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]
ErrorDocument 503 /custompage.html
ErrorDocument 500 /custompage.html
</IfModule>
# END WordPress
But, still it seems to be not working during a 500 or 503. What should I do to make my custom pages to work? - Please help

Why don't you try using the whole URL, to make sure that there is not any problem there.
ErrorDocument 500 http://error.example.com/server_error.html

Related

permanent links are working but /%postname%/ not

Default permanent links are working fine, but when I try to change it to /%postname%/ or any other type, It is showing the following error.
Anyone have an idea why it is happening..?
Server : ubuntu 20.04
Add the following code in your .htaccess file:
# 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

Website giving me 500 internal server error - is it .htaccess error?

My website is giving a 500 internal server error when I click on any category header menu, but the homepage is loading fine. I did some troubleshooting, but from my understanding it narrows down to .htaccess rewrite rules.
Here is my .htaccess code, I need help with this please:
My .htaccess code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
You can replace your .htaccess file with 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
Troubleshooting 500 internal server error
Go FTP into your website
Open the file named wp-config.php
Find the line where you see define('WP_DEBUG', false);
Change false to true and save the file
Now you check..

Wordpress returns 404 on existing file

I have the following stucture:
Wordpress installed in root, and an /api/api.php file manually created
When I go to www.example.com/api/api.php I get a 404
This is my .htaccess in the root folder:
Options +FollowSymLinks
RewriteRule ^api/api\.php$ - [L]
# 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 expect this should have let requests to /api/api.php through unmolested.
Also, I tried putting in a .htaccess file in /api with just
# disable the rewrite engine
RewriteEngine off
but I am still getting a 404 error despite this.
The rest of the site works fine, and I have tried disabling all WP plugins just in case.
try change your permalink from admin panel or if you have an IIS7 server then your permalink should be like %postname%index.php.
and also try this .htaccess code and instead of 'example' write your site base path name
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]

301 redirect wont work but was working previously /tag/ url?

I am using the .htaccess file to create 301 redirects.
redirect 301 /example/page http://www.example.com
the above code has work wonders and has got the job done.
then i got this link in my web crawl errors :
http://www.example.co.za/tag/legislative-framework/www.linkedin.com
If you put the link in your url it takes you to this link:
http://www.example.co.zawww.linkedin.com/
This is what my htaccess file looks like
# 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
How do i create a redirect for this situation?
Not sure if this is caused by your htaccess or your redirect statement. But if you have wordpress, you should stick with using mod_rewrite instead of mod_alias (Redirect 301) because they'll both affect the same URI and you'll get unexpected results:
RewriteRule ^example/page/(.*)$ http://www.example.com/$1 [L,R=301]
# 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

All my pages apart from index lead to a 404 page

My settings for permalinks: default : /?p=123 works but if I switch to by post name All pages stop working and just go to a 404
Check your permalink settings and see if you have enable rewriting in your .htaccess
# 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>

Resources