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?
Related
Why is it possible to go further into my index.php file as it was a folder like: www.domain.com/index.php/put_anything_here_and_it_loads_the_file_without_styling
I want it to use the .htaccess to redirect them to the index.php when they go to a file that does not exist like index.php/anything_here - but for some reason it thinks that index.php/anything_here exists...
Right now i have just set my .htaccess to redirect to this page if one of the errors happen:
This is my .htaccess:
ErrorDocument 404 /404error.php
ErrorDocument 400 /404error.php
ErrorDocument 401 /404error.php
ErrorDocument 403 /404error.php
ErrorDocument 500 /404error.php
Thanks
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/
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
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>).
I have setted up my .htaccess with some bundles of rewrites, although when I go to an invalid directory which the ErrorDocument 404 is already set up, it just shows "404" on the page, nothing else, just a plain text with "404".
RewriteEngine on
RewriteBase /
RewriteRule ^404/?$ 404.php
ErrorDocument 404 404
Why doesn't it show the 404 page, if I go to 404.php or http://www.mydomain.com/404 it shows just fine, why won't it show the page?
You need to reformat your .htaccess, see:
http://www.javascriptkit.com/howto/htaccess2.shtml
The correct line is:
ErrorDocument 404 /errors/notfound.html