When i change the code and add something new it doesnt even lets me load my normal page. If delete the ErrorDocument 404/error.php(and the others) I can normally enter my site.
Here is my sites domain: carnageband.tk
Here is the code:
# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
What should i do to bypass the page which it redirects me? LINK
I just had the same problem and the issue seemed to be coming from the .htacess file. The webpage would load okay again after I deleted the .htaccess file.
I was able to fix it by editing the .htaccess file from the cPanel, File Manager instead of transferring the file over FTP, but I'm not really sure why it wasn't working before.
My code looks similar to yours:
# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /
ErrorDocument 403 /errors.php?p=403
ErrorDocument 404 /errors.php?p=404
ErrorDocument 500 /errors.php?p=500
Related
My custom 404 error page only seems to work online for URLs that contain directories that don't exist. If I only have a non-existing file (in an existing directory tree), then I get - instead of my desired custom 404 page - a blank page with "File not found". Seems like, no matter if I have a non-existing file or an existing file in my URL, I only get my custom 404 page when there is a non-existing / misspelled directoy somewhere in the URL. Offline, on Xampp it works fine, though. Can anybody point me in the right direction as to what I might be doing wrong?
This is what my ".htaccess" looks like, which I put in my root directory along with my custom error page:
ErrorDocument 400 /error404.php
ErrorDocument 401 /error404.php
ErrorDocument 403 /error404.php
ErrorDocument 404 /error404.php
ErrorDocument 405 /error404.php
ErrorDocument 408 /error404.php
ErrorDocument 500 /error404.php
ErrorDocument 502 /error404.php
ErrorDocument 504 /error404.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA]
</IfModule>
Update: It seems that the cause of my problems is the file extention ".php". If I call files that don't exist with an extention ".php" I get "File not found". If I use the extention ".html" in my query my custom 404 error page works alright.
example with html extention
example with php extention
Technial Support from my hosting provider suggests to have a look at my configuration where I include extentions. I am not sure where I should look to be honest. Maybe someone can narrow this down?
I have to further test this, but the following lines in my .htaccess file might do the trick:
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^.+\.php$ /non_existant_file
This is my error page i dont know exactly what is but i want to redirect this kind of error to 404.html page:
I have created a 404 error page name "404.html". I want to redirect to this if no file or folder exist in my server.
Where do I have to place this page (404.html)?
Is it possible to redirect this page in .htaccess (or possible with only .htaccess)?
If is there anything more about 404 page let me know, I want to grab the knowledge.
And don't vote me down if possible of copy!
I want to map one error document file for 404 500 i am trying with this code.
ErrorDocument 404 /404.html
ErrorDocument 500 /404.html
RewriteEngine On
RewriteBase /
# map them to one error document:
RewriteCond %{REQUEST_URI} ^/404/$ [OR]
RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ /404.html [L]
I tried this code and uploaded the file in main folder www.website.com/404.html
Its easier then I expected just gave full url:after reading documentation.and it worked.
ErrorDocument 404 http://www.website.com/404.html
ErrorDocument 500 http://www.website.com/404.html
No answer needed.
Where you want on your server
Yes : ErrorDocument 404 /yourPath/404.html
Google and Apache docs are your friends.
Edit : You add an image on your question. This is a 500 Internal Server Error, and not a 404 Page not Found error. Handle it with
ErrorDocument 500 /yourPath/500.html
But if your .htaccess file is corrupted and cause this error, you first have to fix your .htaccess file.
You can specify the document for error handling inside .htaccess similar to one below
ErrorDocument 404 /404.htm
This will override apache's default 404 page. The 404.htm will be inside your root folder.
https://www.addedbytes.com/articles/for-beginners/error-documents-for-beginners/
hy,
I have these lines in my .htaccess file.
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
ErrorDocument 500 /404.php
the problem is, I guess, that the styleshets that are linked inside the 404.php page, load or don't load depending on whether I get the error from a file that is inside a subdirectory or that is in the root directory.
so when I access a file that in lets say
/include/file.php
then the css usually doesn't load, but if the file is in root like
/file.php
then it does load.
does anybody have an answer?
I know how to create a custom error page using the apache htaccess file:
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
But is it possible to have a custom error page without using the htaccess file?
I have access to the server and all its settings
You can use the same code inside your apache virtualhost ; it will have the same behaviour.
Am trying to make a custom 404 page for my website and am having .htaccess file in the root directory where am using this rule
ErrorDocument 404 404.php //I want to redirect to 404
So when I change a valid file name like home.php to home1.php it doesn't redirect me instead it echo's 404.php on that page
Side Note: 404.php is in the root directory only
This should do it
RewriteEngine on
ErrorDocument 404 http://www.yoursite.com/404.php
In your .htaccess file, you should be able to use:
RewriteEngine on
ErrorDocument 404 /404.php
You can set additional error documents using this method, but I'd put them in a separate errors directory:
ErrorDocument 400 /errors/400.php
ErrorDocument 401 /errors/401.php
ErrorDocument 403 /errors/403.php
ErrorDocument 404 /errors/404.php
ErrorDocument 500 /errors/500.php
you could do the following to 404 old pages with your htaccess
RewriteEngine on
ErrorDocument 404 /404.php
but i would personally recommend
RewriteEngine on
RewriteRule home.php /home1.php [R=301,L]
as this would do a 301 redirect from the old page name to the new page name, so any cached search engine results would still end up at the correct page instead of hitting a 404
In my case, using an Ubuntu distribution, the directive ErrorDocument has no effect if it is in the .htaccess in htdocs directory or elsewhere: it turned out that it should be put in the proper /etc/apache/sites-enabled/*.conf file, inside the <VirtualServer> directive (for example, if the website is providing https pages, inside the directive <VirtualHost *:443>).