Im trying to load a custom error document for a 404 error using a .htaccess file on a linux server, the page gets the current page URL then redirects to another site (which is retrieved from a db) based on an id it retrieved from the URL.
The current error documents are stored here:
/error_docs/
- i dont have permission to upload anything other than the HTML files that are already in there
/HTTPDocs/301redir.php
is the site root where the .htaccess file is.
i have used the following to load the 301redir.php page as the error doc, which works in FF but no other browsers.
ErrorDocument 404 /310redir.php
using .htaccess is my only real option for changing this, is there a way to get around this issue and make it work across all browsers?
Maybe your file is too small, see the following excerpt from the apache docs:
Microsoft Internet Explorer (MSIE)
will by default ignore
server-generated error messages when
they are "too small" and substitute
its own "friendly" error messages. The
size threshold varies depending on the
type of error, but in general, if you
make your error document greater than
512 bytes, then MSIE will show the
server-generated error rather than
masking it. More information is
available in Microsoft Knowledge Base
article Q294807.
That should work fine, try putting the full URL http://www.yourdomain.com/301redir.php
I also note that youu said 310redir.php is your example but 301redir.php in your description (note 310 and 301).
Also don't forget to add header("HTTP/1.1 404 Not Found"); if you are doing a 404
Related
We direct visitors on our website to our online digital catalogue by a link to a PHP script which opens in a new browser tab. The script is passed a parameter which identifies the digital document to be opened (eg: /flipper.php?link=catalogue-gbp or /flipper.php?link=catalogue-euro). The parameter is translated into the id of the document (parmlink), which resides on another site. The link is opened using the PHP header command as below:
header('Location: http://edition.pagesuite-professional.co.uk/launch.aspx?'.$parmlink);
The problem is, Google Webmaster Tools reports all these pages as Soft 404 errors:
www.oursite.com/flipper.php?link=catalogue-gbp&page=249
The script flipper.php does not itself output anything to the browser, it merely serves to translate the parameter into the id of the document and to redirect to it. How can we avoid these Soft 404 errors?
One solution I thought of is to replace flipper.php by a JQuery script, but I am not sure why GWT thinks this is a 404, as the page exists.
Note: since an optional "page" parameter can be passed to open the document at a specific page, these soft 404 errors keep increasing.
soft 404's really hurt your ranking as they consume your crawl quota. Your best bet is to block them from search engines with a robots.txt disallow directive.
Disallow: /flipper.php
I'm using a shared hosting service for my sites and there is a strange situation.
When any php page is accessed from a link (like Google search results page, etc), the page will not open.
The following error is shown:
"Forbidden you don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request."
If the same url is input directly into the browser, the page displays fine.
The situation is not the same for html extension pages, which open properly from links too.
I am not using any .htaccess file.
Permission for files is 644 (I've never changed anything).
This situation is something new, there was not such a problem in the past.
Any advice is welcome.
I am looking for an if script to tell if a page is found or not found in the .htaccess file! It may seem odd but im sure it can work some how.
Ill show you what im tying to do with examples, in 1 folder I want to have two files, Cheese.php and Pizza.php! When they are located inside the folder I want it so if they go to Cheese.php it will act normal but if they land on a page that does not exist in the folder it will go to Pizza.php, but Pizza.php is not a 404 error message but something else handled by php.
You may just say use the 404 DocumentError, but the only problem is that on internet explorer it does not get Pizza.php but displays its own 404 message and on most other browsers it shows an error in the console...
My request seems weird but hopfully this is posible! Thanks
I think using ErrorDocument 404 /Pizza.php in .htaccess may solve your problem.
Or please be clear on what framework you are using?
You may just say use the 404 DocumentError, but the only problem is
that on internet explorer it does not get Pizza.php but displays its
own 404 message and on most other browsers it shows an error in the
console...
The reason you get the error is that the 404 response code is set by your server when the error document is sent. In .htaccess, do:
ErrorDocument 404 /Pizza.php
In Pizza.php, set the response code early in the script, before you output any content to the browser.
<?php
http_response_code(200); //tells browser that everything is OK
...
Because you've set the response code yourself, your server will not set a 404 and the browser will not know that there is any problem.
I'm having issues with my Joomla installation.
It's a rather vanilla J! 2.5 (latest version) installation with K2 (I don't think it is related to my problem).
The problem is that any URL I make up (such as http://www.mysite.com/No-Such-URL-At-All) gives me the following error:
Error
Article not found
You are not authorised to view this resource.
I created an error.php file that should handle it in the template, but it is not used at all by Joomla, as I don't think it is really handled as error but as a permission redirection :\
So I tried adding this code to my template:
Code:
if (($this->error->code) == '404') {
header('Location: /404.html');
exit;
But no error was detected and the code was also ignored.
I inspected the response headers from the server, but I actually get a response 200, OK response :.
Some additional data that could be usefull
- It's hosted on a godaddy dedicated centos server
- SEF is enabled (problem continues also when disabled)
Let me know if any other information could help...
I really have no other direction I can think of, maybe someone has any idea why any 404 is turned into a permission redirection?
Check to see if when you have a 404 if Joomla is hitting the "com_content" component ( check the $_REQUEST variable). I had this problem and it turned out that it wasn't, it was hitting one of my custom components. If this is the case, here is what you need to do to fix it. For this example, lets say that its hitting 'com_home' instead of 'com_content'.
1). Copy components/com_content/router.php into components/com_home
2). Open components/com_home/router.php and replace all instances of "Content" with "home"
3). Open components/com_home/home.php and add the following lines near the top of the file:
JHtml::_('behavior.tabstate');
require_once JPATH_COMPONENT.'/helpers/route.php';
4). Copy the entire components/com_content/helpers into components/com_home
When that's done, the url mysite.com/does-not-exist should redirect to the error.php page you've set up in your template.
I've set up a Drupal 7 site locally and have ftp'd the site over to my ISP's server which is a linux box running PHP and MySQL.
I've never successfully logged into the site before and I have locked myself out. When I go http://www.example.com/?q=user and click on request New Password then I get this error:
Not Found
The requested URL /user/password was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
One thing I've been confused about and that is the .htaccess file. I never had one locally on my Mac and I did not need it (I know it is hidden) - so I downloaded one and deployed it to the web site but then I got 500 errors, it made it worse. I've since deleted that file and at least I get some content - but not very much - just the front page. I overrode the themes name in settings.php as I have user access errors there. I changed it back to one of the default themes and that allowed me to get some content and not the 'white screen of death'
Advice welcome!