Redirect "Page not found" to index

Feel free to talk about everything related to our Joomla Products
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Sun Apr 29, 2012 5:07 pm
Hi,
I had build my website manually but now I have a Joomla/Gavick template so all people using search engines and clicking to any old link reach a page that does not exist anymore "page not found".
Is there anyway that when visitors click on a non existing page they are redirected to the index page or to a page where I write an explanation of the situation?
Thanks.
User avatar
Junior Boarder

GK User
Mon Apr 30, 2012 5:14 pm
Hi,

Under your template's folder you will see file error.php. Open this file and customize it to display anything you want when an user goes to an unexisted page.

Cheers,
User avatar
Platinum Boarder

GK User
Tue May 01, 2012 4:11 pm
Hi Don, thanks for your answer.
I don't know how to customize error.php so I think that the easiest way to do it would be to create a single article with an explanation about why the page is not found.
Is it in this part of the error.php file (below)? Do I have to change "/index.php" for the url address of the single article? Now if the page is not found it is not redirected to index.php, is there anything else to change? Thanks

<ol>
<li><a href="<?php echo $this->baseurl; ?>/index.php" title="<?php echo JText::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?>"><?php echo JText::_('JERROR_LAYOUT_HOME_PAGE'); ?></a></li>
</ol>
User avatar
Junior Boarder

GK User
Tue May 01, 2012 4:19 pm
Hi,

If you want to redirect it to homepage, just delete all the code inside that file and replace by this code:
Code: Select all
<?php

   header( 'Location: http://www.yoursite.com/' ) ;

?>
User avatar
Platinum Boarder

GK User
Tue May 01, 2012 5:12 pm
Marquitus wrote:Hi,
I had build my website manually but now I have a Joomla/Gavick template so all people using search engines and clicking to any old link reach a page that does not exist anymore "page not found".
Is there anyway that when visitors click on a non existing page they are redirected to the index page or to a page where I write an explanation of the situation?
Thanks.


My suggestion is to handle all the redirects from your server rather than the template. If you are familiar with SEO i would also suggest to enable SEF option on joomla so your website will be loaded on yourwebsite.com rather than yourwebsite.com/index.php
You can modify your .httaccess file to handle all the redirects
use redirect 301 /[old relative url] [full new url] (remove [])
User avatar
Junior Boarder

GK User
Wed May 02, 2012 11:25 am
Hi lads, thanks for your answers.
Don, I have changed the code but there is no redirection, example http://www.liffey.cat/economia/1111/iva.html
gsadeghi, I am not familiar with SEO but where in joomla can I enable SEF?
Thanks.
User avatar
Junior Boarder

GK User
Wed May 02, 2012 5:11 pm
It has already worked, check this URL instead: http://www.liffey.cat/index.php/donlee

The link above doesn't work because it doesn't have "index.php" so the server understands that you open file iva.html under folder "/economia/1111/" which doesn't exist.

By the way, you have enabled SEF mode already but not using htaccess file, if you want to learn more, just read http://docs.joomla.org/Enabling_Search_ ... EF%29_URLs

And the suggestion of gsadeghi is correct, it's the best solution if you use htaccess file. The code to add to that file should be:
Code: Select all
ErrorDocument 404 /index.php
User avatar
Platinum Boarder


cron