Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

/index.php vs. /


longhorn1999

Recommended Posts

Hi,

 

I seem to be having an issue with my internal links as they're not showing up at all in Google Webmaster Tools or Yahoo Site Explorer. I have a bit in my .htaccess to make sure that the non-index.php version is what shows up as my home page.

 

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.my-domain.com/$1 [R=301,L]

 

The problem is that when I hover over the logo, the continue button, or the 'home' link in the breadcrumbs, www.my-domain.com/index.php shows up, and this is the case when I view the source.

 

logo in the header:

<td valign="middle"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'storelogo.gif', (tep_not_null($header_tags_array['logo_text']) ? $header_tags_array['logo_text'] : STORE_NAME)).'</a>';?></td>

 

continue button on information pages:

<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>

 

 

But somehow the link I have in my footer to the home page just shows www.my-domain.com/ as I want it to when I hover over it.

 

<p>Copyright © 2010 <a href="<?php tep_href_link(FILENAME_DEFAULT);?>">My Domain Name. All rights reserved</p>

 

Not sure that it's relevant, but I have the latest versions of Ultimate SEO Urls 5 and Header Tags SEO installed.

 

Is anyone else having this issue at all? Any ideas why I might be having this internal linking problem?

 

Thanks,

 

Nick

Link to comment
Share on other sites

I have same problem, I have just changed the links

 

from:

...<a href="' . tep_href_link(FILENAME_DEFAULT) . '">...

 

to:

...<a href="/">...

 

It is not a solution but it works.

 

 

tep_href_link is important for preserving SID, so you might have some comebacks.

Link to comment
Share on other sites

I have same problem, I have just changed the links

 

from:

...<a href="' . tep_href_link(FILENAME_DEFAULT) . '">...

 

to:

...<a href="/">...

 

It is not a solution but it works.

The correct change is

...<a href="' . tep_href_link('/') . '">...

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

The correct change is

...<a href="' . tep_href_link('/') . '">...

 

It looks like this has been discussed before at length with no clear resolution:

http://www.oscommerce.com/forums/topic/155079-remove-index-php-when-browsing-back-to-main-page/

 

 

Changing filename_default seems to work on the surface, but does anyone know if changing it may causes any other problems?

 

Is that the preferred way to make /index.php just /, or is it some version of a 301 redirect in .htaccess?

Link to comment
Share on other sites

Changing filename_default seems to work on the surface, but does anyone know if changing it may causes any other problems?

 

Is that the preferred way to make /index.php just /, or is it some version of a 301 redirect in .htaccess?

You just need to make the change I mentioned. It may cause a // to appear in the link but that is OK. If you want to get rid of that, install the Ultimate SEO contribution and/or a canonical tag contribution. I've made this change to hundreds of sites - it is safe. You should also make the .htaccess change to redirect so index.php is removed. That will fix problems caused by external links to your site being formatted incorrectly.

 

The problem many people make though, as can be seen in that thread, is to remove the index.php for all links. That is a mistake and will cause problems. It should only be removed if there are not any arguments following index.php.

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

You just need to make the change I mentioned. It may cause a // to appear in the link but that is OK. If you want to get rid of that, install the Ultimate SEO contribution and/or a canonical tag contribution. I've made this change to hundreds of sites - it is safe. You should also make the .htaccess change to redirect so index.php is removed. That will fix problems caused by external links to your site being formatted incorrectly.

 

The problem many people make though, as can be seen in that thread, is to remove the index.php for all links. That is a mistake and will cause problems. It should only be removed if there are not any arguments following index.php.

 

 

Would you recommend that this change be made in every single instance where FILENAME_DEFAULT is called, the logo and breadcrumbs in the header and the continue button on various pages? Thanks Jack, I think this info will useful for a lot of people.

Link to comment
Share on other sites

Would you recommend that this change be made in every single instance where FILENAME_DEFAULT is called, the logo and breadcrumbs in the header and the continue button on various pages? Thanks Jack, I think this info will useful for a lot of people.

Yes, it should be used for links to the home page - but only to those without arguments, as already stated.

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

You just need to make the change I mentioned. It may cause a // to appear in the link but that is OK. If you want to get rid of that, install the Ultimate SEO contribution and/or a canonical tag contribution. I've made this change to hundreds of sites - it is safe. You should also make the .htaccess change to redirect so index.php is removed. That will fix problems caused by external links to your site being formatted incorrectly.

 

I made this change and am getting the double slash in the link as you'd predicted. To get rid of it, is there a particular canonical contribution or snippet you might recommend? I've already been using Robert's USU5 as opposed to Chemo's version, and you'd mentioned in the Header Tags SEO forum that Header Tags and Sam's Remove & Prevent duplicate content with the canonical tag shouldn't both be used.

 

Thanks again Jack.

Link to comment
Share on other sites

I made this change and am getting the double slash in the link as you'd predicted. To get rid of it, is there a particular canonical contribution or snippet you might recommend? I've already been using Robert's USU5 as opposed to Chemo's version, and you'd mentioned in the Header Tags SEO forum that Header Tags and Sam's Remove & Prevent duplicate content with the canonical tag shouldn't both be used.

I can't help you with that. You'd need to take that up in the SEO 5 thread since it doesn't happen with Ultimate SEO V2 and Header Tags SEO.

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

I as well, have been looking for ways to eliminate the /index.php when I tick the store logo or links in the header. After editing, I did get the double //. So looked into Canonical URL Links as suggested. Upon finishing and testing product page, both the browser and view source code reveals the sid info.

 

In the first post here, member said this he/she added this code to the .htaccess file

RewriteCond %{THE_REQUEST} ^.*/index.php

RewriteRule ^(.*)index.php$ http://www.my-domain.com/$1 [R=301,L]

 

Was not able to log in to admin. Kept bouncing back to logon page. So I removed that piece of code and now able to login to admin. Did notice if I set admin -> sessions -> force cookies to true, the sid was removed. I have both Header Tags SEO and Ultimate SEO URLs installed. But not sure if that step was actually defeating the purpose of the two SEO's modules installed.

Link to comment
Share on other sites

I as well, have been looking for ways to eliminate the /index.php when I tick the store logo or links in the header. After editing, I did get the double //. So looked into Canonical URL Links as suggested. Upon finishing and testing product page, both the browser and view source code reveals the sid info.

 

In the first post here, member said this he/she added this code to the .htaccess file

 

 

Was not able to log in to admin. Kept bouncing back to logon page. So I removed that piece of code and now able to login to admin. Did notice if I set admin -> sessions -> force cookies to true, the sid was removed. I have both Header Tags SEO and Ultimate SEO URLs installed. But not sure if that step was actually defeating the purpose of the two SEO's modules installed.

 

I had put that bit of code into catalog/.htaccess. You may have put it into catalog/admin/.htaccess instead, which would cause that login problem.

Link to comment
Share on other sites

I found this to be the best fix:

 

http://www.oscommerce.com/community/contributions,4835

 

It requires only two simple steps:

 

First in:

index.php

 

Change:

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

 

To:

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT_HOME);

 

Then, in: includes/filenames.php find:

 

define('FILENAME_DEFAULT', 'index.php');

 

And change it to:

 

// Start index.php fix

// define('FILENAME_DEFAULT', 'index.php');

define('FILENAME_DEFAULT', '');

define('FILENAME_DEFAULT_HOME', 'index.php');

// End of index.php fix

 

Done!

 

If you are using ULTIMATE Seo Urls 5 - by FWR Media, you will need to reset the cache! The urls will stay the same but cache must be reset.

 

If you are using a certain header tags contribution... follow the link to this fix above and a simple fix is available.

 

also...

 

Use this in your htaccess to give a proper redirect to any old incoming index.php links:

 

RewriteCond %{THE_REQUEST} ^.*/index.php

RewriteRule ^index.php$ /$1 [R=301,L]

 

My rewrite will not effect your admin, or cause issues with additional index.php pages you are serving up on your site.

Link to comment
Share on other sites

I found this to be the best fix:

 

http://www.oscommerce.com/community/contributions,4835

 

It requires only two simple steps:

 

First in:

index.php

 

Change:

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

 

To:

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT_HOME);

 

Then, in: includes/filenames.php find:

 

define('FILENAME_DEFAULT', 'index.php');

 

And change it to:

 

// Start index.php fix

// define('FILENAME_DEFAULT', 'index.php');

define('FILENAME_DEFAULT', '');

define('FILENAME_DEFAULT_HOME', 'index.php');

// End of index.php fix

 

Done!

Oh my. That's quite a convoluted mess for such a simple problem. In the least, every contribution you install that needs FILENAME_DEFAULT will most likely fail unless you take extra steps to change the code. Anyone using that method will just be starting to dig a hole they will never finish.

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

............ Anyone using that method will just be starting to dig a hole they will never finish.

 

 

I agree with Jack. You can just use the htaccess redirect that has been posted, and for the rest just use <link rel="canonical" ....> on your pages where required.

Link to comment
Share on other sites

Oh my. That's quite a convoluted mess for such a simple problem. In the least, every contribution you install that needs FILENAME_DEFAULT will most likely fail unless you take extra steps to change the code. Anyone using that method will just be starting to dig a hole they will never finish.

 

 

Did you even look at the two tiny lines of code Jack?

 

FILENAME_DEFAULT

is still there...

 

Read it slower as it is really very basic/simple.

Link to comment
Share on other sites

Did you even look at the two tiny lines of code Jack?

 

FILENAME_DEFAULT

is still there...

 

Read it slower as it is really very basic/simple.

Yes, I see it is there, but it is defined incorrectly for normal operation. Consider what happens if you install a contribution that has a link like tep_href_link(FILENAME_DEFAULT, 'cPath=4'). The resulting link would be http://mysite.com/?cPath=4, which is not correct. I'm not saying the code won't work but that it is not doing it in an oscommerce-friendly way and it will cause problems at some point. If there were no other way, then it would be a solution. But since there is another, simpler and less damaging way, I don't see why someone would use 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...