Psytanium Posted October 26, 2018 Share Posted October 26, 2018 Hello, Google search engine post results of old URLs of my website, after some readings, Google advise to redirect all none found URLs to 404 Not Found, my osc2.3.4 is redirecting all none found links to 404 Not Fount unless the link contain index.php e.g. www.domain.com/asdasda redirect to 404 Not Found, good but e.g. www.domain.com/index.php/asdadasd redirect to home page instead - This is a problem, Search engines keeps those wrong URLs as valid PLEASE HELP, I have people who search for product A on Google, end up at home page instead of product page. Link to comment Share on other sites More sharing options...
MrPhil Posted October 26, 2018 Share Posted October 26, 2018 How are you redirecting "wrong" URLs? Is it in .htaccess (a redirect or rewrite)? Or is it internal to your osC store (in PHP code)? Link to comment Share on other sites More sharing options...
Psytanium Posted October 27, 2018 Author Share Posted October 27, 2018 21 hours ago, MrPhil said: How are you redirecting "wrong" URLs? Is it in .htaccess (a redirect or rewrite)? Or is it internal to your osC store (in PHP code)? I tried and cleared the htaccess file, blank.it still redirect all links containing index.php to home page, I think its somewhere in php. You know where should I look ? Big thanks btw Link to comment Share on other sites More sharing options...
Psytanium Posted October 27, 2018 Author Share Posted October 27, 2018 Previously I have Ultimate SEO URL 5 addon installed, now its removed and I have installed Ultimate SEO URLs. I turned off the addon but no effect. Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 27, 2018 Share Posted October 27, 2018 @PsytaniumSome templates have code in them that cause a redirect to the home page so if you are using a purchased template, that may be the reason. And I've seen sites where something on the server forces a redirect to the index page on not found pages so you may want to ask your host about that. Also, oscommerce doesn't issue 404's, You may end up on a product not found page but the actual header code issued is a 301 or 302. If your site is issuing a 404 or 410, then it contains added code to cause that and, in that case, it may also be causing the redirect. You may want to install the Header Status Handler to correct the header codes. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
MrPhil Posted October 27, 2018 Share Posted October 27, 2018 7 hours ago, Psytanium said: I tried and cleared the htaccess file, blank. That's unlikely to fix anything. Most SEO systems use rewriting in the .htaccess file to get the URL into an internally usable format. You don't clear the .htaccess; you understand what it's doing first! Link to comment Share on other sites More sharing options...
Psytanium Posted October 30, 2018 Author Share Posted October 30, 2018 On 10/27/2018 at 7:56 PM, Jack_mcs said: @PsytaniumSome templates have code in them that cause a redirect to the home page so if you are using a purchased template, that may be the reason. And I've seen sites where something on the server forces a redirect to the index page on not found pages so you may want to ask your host about that. Also, oscommerce doesn't issue 404's, You may end up on a product not found page but the actual header code issued is a 301 or 302. If your site is issuing a 404 or 410, then it contains added code to cause that and, in that case, it may also be causing the redirect. You may want to install the Header Status Handler to correct the header codes. I did some tests I tried 4 other oscommerce websites on the same server, with or without URL mod, same results, domain.com/index.php/test redirect to to home page. I tried to open domain.com/test the result is 404 not found. As you said, wrong products_info.php URLs end up on a product not found page. On the same server, I opened a Wordpress website, URL domain.com/index.php/test, the url redirect to domain.com/test (index.php removed) and displayed page not found 404. I tried 3 Opencart websites, on the same server. The result is similar to oscommerce, domain.com/index.php/test redirect to home page Conclusion This problem is not related to template or oscommerce or to URL SEO addons. All my websites on my server, with wrong URLs containing index.php redirect to to home page, and the results on search engine is wrong. Only WordPress websites redirect properly. Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 30, 2018 Share Posted October 30, 2018 1 hour ago, Psytanium said: All my websites on my server, with wrong URLs containing index.php redirect to to home page, and the results on search engine is wrong. Then you should contact your host to see what is causing that. It might be a good idea to create a sub-directory and upload an index.php file to it that just has some text, like "hellow." Then try to access a non-existent location in it. If it redirects to the home page, you can use that to show your host the problem. The reason is that a typical answer given by many hosts is that it is the package you are using. If you can't reproduce the problem that way, then there may be something in the shop causing it. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Psytanium Posted October 31, 2018 Author Share Posted October 31, 2018 On 10/30/2018 at 1:48 PM, Jack_mcs said: Then you should contact your host to see what is causing that. It might be a good idea to create a sub-directory and upload an index.php file to it that just has some text, like "hellow." Then try to access a non-existent location in it. If it redirects to the home page, you can use that to show your host the problem. The reason is that a typical answer given by many hosts is that it is the package you are using. If you can't reproduce the problem that way, then there may be something in the shop causing it. I did what you suggested, the cPanel support replied : Quote it appears your issue is specific to how PHP query strings are handled. When loading a PHP file through the Apache service, any characters after the file are handled as query strings. This is the default behavior in the Apache service and allows for PHP query string support. I did some tests on 2 other servers from different providers, apparently all servers behave the same regarding this issue. I noticed that only WordPress can take care and lead those wrong URLs to 404 Not Found where it should be, maybe htaccess is the only way to work around my problem. Link to comment Share on other sites More sharing options...
MrPhil Posted October 31, 2018 Share Posted October 31, 2018 OK, so your server is set up to treat anything after index.php as a Query String? That's a bit unusual, as I understand it, but let's see what we can do with it. You have www.domain.com/index.php/good_product working OK, while www.domain.com/index.php/no_longer_a_product is going to the home page (just /index.php)? And you desire that it 404? If the server (externally to osC) is converting /*_product to a URL Query String, apparently osC + add-on is handling it correctly, but if there's no product match it's simply dumping it back to /index.php. That would require a change to osC + add-on, but did it ever handle no_longer_a_product as desired (404)? I'm trying to get a handle on what this thing is doing -- the SEO I'm familiar with uses .htaccess to convert to /index.php?id=value format. It should be easy enough to change the code to do a header() call to 404 rather than to /index.php (or simply take an internal path to the front page). The question is, how did it used to work, and what changed? Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 1, 2018 Share Posted November 1, 2018 On 10/26/2018 at 12:26 PM, Psytanium said: index.php/asdadasd I missed the above in your original post. That is an invalid part of the url (the format, not the actual one shown). How would that ever happen in your site? Does google have such links in webmastertools? Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Psytanium Posted November 1, 2018 Author Share Posted November 1, 2018 6 hours ago, Jack_mcs said: I missed the above in your original post. That is an invalid part of the url (the format, not the actual one shown). How would that ever happen in your site? Does google have such links in webmastertools? I used Ultimate SEO URL5 for some years, this addon use this URL format domain.com/index.php/product_name, so Google now saved my URLs based on this format. 6 months ago, I switched to another SEO URL addon, I think 1 of your contributions, it use another URL format domain.com/product_name.html That's how I ended struggling with Google to get him forget my URLs, but this need old wrong URLs to display the dead end a 404 Not found. Instead, old URLs display the content of domain.com/index.php @MrPhil explained whats happening correctly, any URL string following index.php is treated as URL parameter and if there's no product match it's simply dumping it back to /index.php According to cPanel support this is a standard behavior any server running Apache. Here is a link for testing, I uploaded a index.php to an empty account, there no htaccess or any platform installed: http://lbeautyspot.com/index.php http://lbeautyspot.com/index.php/product_name <- this URL must lead to dead end 404 Not Found in order to make Google clear it from its archive. Thank you both for digging this issue with me Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 1, 2018 Share Posted November 1, 2018 4 hours ago, Psytanium said: I used Ultimate SEO URL5 for some years, this addon use this URL format domain.com/index.php/product_name, so Google now saved my URLs based on this format. Ahh, I forgot about that usage. I said at the time, and quite a few times later, that it was a bad idea to use that method. I don't support a different url addon so I can't comment on the second one you used. This addon will issue 301 redirects for stock url's but not for the SEO 5 url's. You would need to add redirect code to handle those url's. Unfortunately, there's no way to do that from the .htaccess file, at least that I am aware of, short of one at a time, of course. I think you would need to add code to the application top file that checks for that format and issues a rewrite, or a 404 if the item no longer exists. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Psytanium Posted November 1, 2018 Author Share Posted November 1, 2018 1 hour ago, Jack_mcs said: Ahh, I forgot about that usage. I said at the time, and quite a few times later, that it was a bad idea to use that method. I don't support a different url addon so I can't comment on the second one you used. This addon will issue 301 redirects for stock url's but not for the SEO 5 url's. You would need to add redirect code to handle those url's. Unfortunately, there's no way to do that from the .htaccess file, at least that I am aware of, short of one at a time, of course. I think you would need to add code to the application top file that checks for that format and issues a rewrite, or a 404 if the item no longer exists. Indeed its a bad idea to include index.php in the URLs. cause what follow is considered parameters only. Now I'm using your contribution, the reason I switched because there is a better support generating sitemaps. Anyway, I think osCommerce must do something regarding this issue, WordPress included a solution for this possibility. Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 1, 2018 Share Posted November 1, 2018 @Psytanium Oscommerce doesn't have anything to do with this since it is not in the core code. I think there should be an option to rewrite url's built in but it's not up to me. So the only choice, in a case like this is provide your own solution. If there are not too many url's, you can edit them in webmastertools so they point to the correct page. But anymore than 10 or 20 would be too many, as far as I'm concerned. So short of a code change, I think you have to live with it. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
MrPhil Posted November 1, 2018 Share Posted November 1, 2018 The code for USU5 has been removed, you say, so now /index.php simply receives a Query String (name and empty value?) and ignores it because there is no code telling it how to handle it? Does this happen for both invalid products and those that are still live? I would think it would. My server isn't configured to work this way, so I can't tell exactly how yours is handling it, but something like foreach ($_REQUEST as $key => $value) { if $key == known request, continue; if $key == known request, continue; // $key is a product name redirect to 404 or 301 } might work. USU5 was presumably checking product names against the database, and if a product was missing, give some sort of 404 response. If you still have the code, you might be able to look at it and put in a stub to handle it (301 to the current URL for that product, if it's live, and otherwise 404). Hopefully you can do that, otherwise you'll be re-inventing a big chunk of the USU5 wheel! Link to comment Share on other sites More sharing options...
Psytanium Posted November 2, 2018 Author Share Posted November 2, 2018 22 hours ago, MrPhil said: The code for USU5 has been removed, you say, so now /index.php simply receives a Query String (name and empty value?) and ignores it because there is no code telling it how to handle it? Does this happen for both invalid products and those that are still live? I would think it would. My server isn't configured to work this way, so I can't tell exactly how yours is handling it, but something like foreach ($_REQUEST as $key => $value) { if $key == known request, continue; if $key == known request, continue; // $key is a product name redirect to 404 or 301 } might work. USU5 was presumably checking product names against the database, and if a product was missing, give some sort of 404 response. If you still have the code, you might be able to look at it and put in a stub to handle it (301 to the current URL for that product, if it's live, and otherwise 404). Hopefully you can do that, otherwise you'll be re-inventing a big chunk of the USU5 wheel! Thanks.. I will try your solution next week and post back the result.. bug thanks Link to comment Share on other sites More sharing options...
Psytanium Posted November 3, 2018 Author Share Posted November 3, 2018 Solution provided on webhostingtalk forums: RewriteEngine On RewriteRule ^index\.php/(.*)$ http://%{HTTP_HOST}/$1 [R=301,L] To fix USU5 problem you can change it to: RewriteEngine On RewriteRule ^products_info\.php/(.*)$ http://%{HTTP_HOST}/$1 [R=301,L] Finally Link to comment Share on other sites More sharing options...
MrPhil Posted November 3, 2018 Share Posted November 3, 2018 The first solution is wrong. It forces the URL to http (non-SSL), which is not what you want these days (https/SSL is much preferred), and potentially adds or removes www from the domain name, which may not be desirable. To simply remove the "index.php/" part from the URL (if that works for you): RewriteEngine On RewriteRule ^index\.php/(.*)$ /$1 [R=301,L] which would not disturb the protocol (http or https) or the domain name that you may have adjusted already. The same comments apply to the second solution. In both cases, the browser (or search engine) gets a bounceback that says, "use this new URL instead of that old one you sent me." You want to try to avoid multiple 301 or 302 status messages (combine them into one if possible) so you aren't penalized by search engines. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.