404 with htaccess

Hi,



knows somebody how can I disable parsing of the original 404 page of CS Cart?

I can’t find any solution, I want to redirect the 404 error page to the home page through htaccess but it doesn’t work, it shows still the CS Cart 404 parsed through exception.tpl file.



Thanks.

edit the exception.tpl file under /skins/skin_name/customer/exception.tpl



replace it’s content with:



{php}

header(“Location: /”);

{/php}



That’s the easiest way to implement what you want. Not the “correct” way by any means, but it will work.

[quote name=‘vqcdesigns’]edit the exception.tpl file under /skins/skin_name/customer/exception.tpl



replace it’s content with:



{php}

header(“Location: /”);

{/php}



That’s the easiest way to implement what you want. Not the “correct” way by any means, but it will work.[/quote]



Hi, thanks for the tip.



That works as well:


I use Javascript to redirect customers without they ever noticing it. with the HTML tag they will always see for a moment the error page and with Javascript they don’t see it at all. Besides, it is said that google doesn’t like this particular html tag.



The code goes in the same place as the html one:


[quote name=‘E.Qi.Librium’]I use Javascript to redirect customers without they ever noticing it. with the HTML tag they will always see for a moment the error page and with Javascript they don’t see it at all. Besides, it is said that google doesn’t like this particular html tag.[/quote]



Although the meta refresh often gets abused to trick visitors into popup hells by sneaky pages on low-life free hosts (poor man’s cloaking), search engines don’t treat every instance of the meta refresh as Webspam. Folks moving their free hosted stuff to their own domains rely on it to redirect to the new location:

[quote][/quote]META Refresh: is recognized as a 301 if it specifies little or no delay or as a 302 if it specifies noticeable delay.



Best idea is to use 301/302s directly whenever possible; otherwise, next best is to do a metarefresh with 0 for a 301. I don’t believe we recommend or support any 302-alternative.



The number of users surfing with meta-refresh=off is only a tiny fraction of your visitors, and using JavaScript redirects is way more risky (WRT picky search engines) than a zero meta refresh. Also, JavaScript redirects “-if” captured by a search engine– should count as 302 and you really don’t want to deal with all the disadvantages of soft redirects.

I must disagree with part of it as search engines continue interpreting the exception page as an 404 not found and not as 301 or 302.

I don’t see how could it make a difference in putting javascript or html to redirect in terms of 301 or 302, it will always be the exception page, this meaning, 404 page not found. Of course, I’m speaking in terms of putting these codes into the exception page.



There is an online tool where you can check how search engines view your exception page by inputing an old url that you know that is going to fall on the exception page:



[url]Check Server Headers Tool - HTTP Status Codes Checker | SEO Consultants Tools



The php solution will give search engines an 302 redirect, wich, depending on what you want maybe good or bad. I think it is better to give the 404 not found so that google and others can refresh you site indexing removing old pages and replacing them with new ones.

Yes, and that is the problem, because I can’t make a server side redirect where the header send a 200 OK to the SE.

Well, I have a similar problem, can’t make the 301 moved perm. in htaccess for my old shop pages, it does not respond well to this command, don’t know why, so, 404 it must be untill google removes all of them.

[quote name=‘E.Qi.Librium’]Well, I have a similar problem, can’t make the 301 moved perm. in htaccess for my old shop pages, it does not respond well to this command, don’t know why, so, 404 it must be untill google removes all of them.[/quote]



If you will keep the ranking of your old pages, the you can use this htaccess rule:



For categories redirect:


[quote]RewriteEngine on

RewriteCond %{query_string} your_old_category_string

RewriteRule (.*) h**p://www.yourdomain.com/something/new_category/? [R=301,L][/quote]For pages:


[quote]RewriteCond %{query_string} your_old_page_string

RewriteRule (.*) h**p://www.yourdomain.com/something/new_category/new_page.html? [R=301,L][/quote]

Thread has officially been derailed. (Once Again)



@vqcdesigns

Just verifying that the method you posted still allows CS to be the “Handler” of the header response codes? I presume changing to “/” will just redirect them to the homepage without notification?

Here is the answer from cs-cart support I get.



In order to redirect a customer to the custom page of 404 error you should replace the following part of code:


if ($status == CONTROLLER_STATUS_NO_PAGE) {
header(' ', true, 404);
}






with this one:


if ($status == CONTROLLER_STATUS_NO_PAGE) {
fn_redirect(Registry::get('config.http_location') . "/404.html");
}






in the “fn.control.php” file located in the “core” directory of your CS-Cart installation and put the “404.html” page to the root directory of your CS-Cart installation.

[quote name=‘kocalka’]Here is the answer from cs-cart support I get.



In order to redirect a customer to the custom page of 404 error you should replace the following part of code:


if ($status == CONTROLLER_STATUS_NO_PAGE) {
header(' ', true, 404);
}






with this one:


if ($status == CONTROLLER_STATUS_NO_PAGE) {
fn_redirect(Registry::get('config.http_location') . "/404.html");
}






in the “fn.control.php” file located in the “core” directory of your CS-Cart installation and put the “404.html” page to the root directory of your CS-Cart installation.[/QUOTE]







[COLOR=“Black”]I just changed the “/404.html” to “/index.php” and they are just sent to the home page.

Works great thanks,
[/COLOR]

I did the same works great!

Hi,



I am still on 1.3.5 (Too many custom mods) and could not locate fn.control.php in the root directory. Is this file under a different name in 1.3 or is there an equivalent?

Thanks folks

The fn.control.php edit worked great for me too, just altered it to index.php as above

Thank you Kocalka


[quote name=‘kocalka’]Here is the answer from cs-cart support I get.



In order to redirect a customer to the custom page of 404 error you should replace the following part of code:


if ($status == CONTROLLER_STATUS_NO_PAGE) {
header(' ', true, 404);
}






with this one:


if ($status == CONTROLLER_STATUS_NO_PAGE) {
fn_redirect(Registry::get('config.http_location') . "/404.html");
}






in the “fn.control.php” file located in the “core” directory of your CS-Cart installation and put the “404.html” page to the root directory of your CS-Cart installation.[/QUOTE]







Lee Li Pop

[quote name=‘kocalka’]and put the “404.html” page to the root directory of your CS-Cart installation.[/QUOTE]



Or, you can create a new page:



Content > Pages



Name of this new page:



404 (or Oooops!)



Description:



We’re sorry. The page is not active on this site.



Go to Home Page (with real link)



Status:



Hidden



Save.





Lee Li Pop

Thanks it works nice.

[quote name=‘CutRiteFX’ timestamp=‘1266441613’ post=‘71064’]

[COLOR=“Black”]I just changed the “/404.html” to “/index.php” and they are just sent to the home page.

Works great thanks,
[/COLOR]

[/quote]

I have been trying for days to figure out how to modify the .htaccess file to redirect broken links to the index.php page and just came across this solution. YEEEHAAA, it fixed our problem as well!

MUCH OBLIGED!!!

:D

[quote name='Lee Li Pop' timestamp='1305434222' post='112303']

Or, you can create a new page:





Content > Pages





Name of this new page:





404 (or Oooops!)





Description:





We're sorry. The page is not active on this site.





Go to Home Page (with real link)





Status:





Hidden





Save.







Lee Li Pop

[/quote]



I was using this by your suggestion for last 6 months but in last few days I came to know by some redirect checkers this method cause 302 redirect which is not SEO friendly now Google webmaster tool is also reporting soft404s