I am trying to Custom Error Pages using .htaccess. in this folder:/home/tamp/public_html/sandbox/test, I put .htaccess file, and inside i put this line:
ErrorDocument 404 /home/tamp/public_html/sandbox/test/error.html,
and then in frontend, I did a test, I open mysite/sandbox/test/te.php(te.php does not exist), but it still shows the default error page: The requested URL /test/tes.php was not found on this server. My error.html did not show up.
So what may go wrong here?
with ErrorDocument you can't use full file-system path:
URLs can begin with a slash (/) for local web-paths (relative to the
DocumentRoot), or be a full URL which the client can resolve.
so assuming that your website root folder is sandbox:
ErrorDocument 404 /test/error.html
Related
I edited the .htaccess file on my site, and added the line
ErrorDocument 404 page-not-found.html
So when I put in example.com/pagethatdoesntexist, the screen just displays "page-not-found.html". Why does this happen?
As per Apache reference documentation, URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve.
So in your case, this should do the job.
ErrorDocument 404 /page-not-found.html
With no /, your webpage name will be treated as a message and printed in the browser.
Server gives a 404 error instead of serving up an index.php or index.html file on the www.domainname.com call. If I type in www.domainname.com/index.php it works fine, but not otherwise. This domain is an add-on domain to my existing cpanel installation, so I don't know if that is related. Permissions are set to execute on the file. I tried creating a .htaccess file in the directory with the following:
DirectoryIndex index.php
This did not work. Wondering how I can troubleshoot this. Running LiteSpeed Web Server on shared hosting. What could be causing this?
When I renamed .htaccess to .htaccess.bak in the parent directory, everything worked as expected. It seems there is probably an error in that .htaccess file that is propagating sub-directories as well. I will need to figure out exactly what is wrong, but that lies outside the scope of this question.
Was tipped off to the idea by: http://www.bluehostforum.com/showthread.php?38079-automatically-serve-index-html-in-subdirectories-solved
I have a domain domain.com
And when I type domain.com/something.html/new/one/square/new.html I am not getting a 404 error.
Where something.html is present in the account correctly.
Directory new is present in my document root.
Square is not present in my account.
By default, if part of the url points to a file, the rest of the url is treated as so-called "path info". In php you should be able to get this path info by checking $_SERVER['PATH_INFO']. If you don't want Apache to work like this, turn path info off in your main config file (httpd.conf) or in .htaccess in your root directory with the following directive.
AcceptPathInfo Off
For more information, please check the documentation for AcceptPathInfo.
I have a website thats live and another (for amends/approval) that is in a subdirectory called 'approval'. The idea being that once its approved I replace the live site. Is there a way to restrict access to this directory unless you have a direct link - maybe through .htaccess? Any other suggestions regarding protocol for this scenario? Thanks!
I've tried something with .htacces.
You can make a 403 error page. You can't go to a directory unless you have a link.
Make a .htacces file with the following code:
## Error Page
ErrorDocument 403 /403.html
Options -Indexes
the ## means that the line is hidden, for text
ErrorDocument 403 gives the place of the 403 error file. You can also type this: /errors/403.html
Options -Indexes blocks the directory's
I hope that it works for you
I receive a 404 problem:
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
My .htaccess looks like this. My .htaccess and index.html is within the 'bar' folder:
ErrorDocument 403 /public_html/foo/bar/errorpages/403.html
order deny,allow
deny from all
allow from 123.456
I also have a .htaccess in my errorpages:
order deny,allow
allow from all
Am i redirecting it wrong?
UPDATE
I have also tried changing the directory to
/bar/errorpages/403.html
But still same problem :(
Try using
order allow, deny
instead.
Look at examples here.