Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Remove index.php when browsing back to main page


Guest

Recommended Posts

  • Replies 80
  • Created
  • Last Reply

A little update;

 

Complete Instructions:

Remove index.php when browsing back to main page

Note: these instructions assume you're running UltimateSEO

 

0. Like always - back up any file before you change it on the server.

 

1. Add this line to the list of defines in catalog/includes/filesnames.php

define('FILENAME_HOME', '/');

(note; do not replace or change

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

doing that will break your store)

 

2. Change all occurances of

(FILENAME_DEFAULT) to (FILENAME_HOME) found in all of the following files. (These are all in your catalog directory)

about_us.php

all_products.php

checkout_success.php

conditions.php

cookie_usage.php

create_account_success.php

gv_redeem.php

login.php

logoff.php

privacy.php

product_info.php (this only occurs if you go to a product not found) test: http://yoursite/-p-.html

redirect.php

shipping.php

shopping_cart.php

(cloned about_us.php custom pages you named) ours were: services.php & overview.php

 

3. At this point you have pretty much eliminated seeing yourdomain/index.php but you can still call it up in your browser. Special thanks to Cannuck1964, for the modification to the .htaccess file.

Added at the end of the .htaccess which is directly after all the RewriteRule stuff

& (I believe this is still part of)

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

 

 

# Eliminates duplicate home page i.e.: www.domain.com/index.php and www.domain.com appear as duplicate home page 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://www.put_your_domain_here.com/ [R=301,L]

 

 

Also, will it break the store if I miss some while attempting this?

Thanks

Tom

Tom, hopefully the above will help you (and anyone else).

If your store works and includes/filenames.php has this: define('FILENAME_DEFAULT', 'index.php'); -I'll bet it does! Then it needs no reference to "catalog" or any directory at this point, just add define('FILENAME_HOME', '/'); to the list.

Link to comment
Share on other sites

The htaccess method is perfered, since all of you are running live shops I assume. The re write also notifies the search engines this is a perminate move and they will adjust they listing accordingly. I would not be bothered editing all of this pages, as this seems like a complex way of doing a simple rewrite of the URL (in a similar manor that SEO does).

 

The changing of the code as described will work, but it will also still show duplicate content to the search engines (and be penalized for it), since the url /index.php is still present in the site. While the mod rewrite will always change the url to "/" and notify the search engine it is perminate. This will work for shops being in the root or in any sub directory as well.

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

Hey thanks for the .htaccess bit, but wouldnt that be same as a redirect? Just curious.

 

Eric

I wish we could get one of the really smart php coders to comment here...

 

All I know is prior to adding the .htaccess bit both my page & yours were still accessible as domain/index.php but (for instance) java roasters website was not. When you think about it all our html product pages with UltimateSEO's are a sort of redirect too. I assume (insert snide comment from Boxtel here) the .htaccess type redirect is better than any other sort of script or html redirect.

Cheers & happy black friday.

Joe

Link to comment
Share on other sites

I wish we could get one of the really smart php coders to comment here...
Sorry, just a simple farmer here :)

 

All I know is prior to adding the .htaccess bit both my page & yours were still accessible as domain/index.php but (for instance) java roasters website was not.
Yes, but now if you try to access my site with the /index.php you will not see the /index.php part anymore (rewritten) and the search engine is told that this is a permenate move. I have had this in place for many months now and never had an issue with it.

 

When you think about it all our html product pages with UltimateSEO's are a sort of redirect too. I assume (insert snide comment from Boxtel here) the .htaccess type redirect is better than any other sort of script or html redirect.
Yes, the SEO urls is a rewrite, it is not a redirect. They are different. And yes this is the best way to do this since redirects are not the best way of dealing with this (the search engine will still try in the future to access /index.php as it does not know better).

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

  • 3 weeks later...
A little update;

 

Complete Instructions:

Remove index.php when browsing back to main page

Note: these instructions assume you're running UltimateSEO

 

0. Like always - back up any file before you change it on the server.

 

1. Add this line to the list of defines in catalog/includes/filesnames.php

define('FILENAME_HOME', '/');

(note; do not replace or change

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

doing that will break your store)

 

2. Change all occurances of

(FILENAME_DEFAULT) to (FILENAME_HOME) found in all of the following files. (These are all in your catalog directory)

about_us.php

all_products.php

checkout_success.php

conditions.php

cookie_usage.php

create_account_success.php

gv_redeem.php

login.php

logoff.php

privacy.php

product_info.php (this only occurs if you go to a product not found) test: http://yoursite/-p-.html

redirect.php

shipping.php

shopping_cart.php

(cloned about_us.php custom pages you named) ours were: services.php & overview.php

 

3. At this point you have pretty much eliminated seeing yourdomain/index.php but you can still call it up in your browser. Special thanks to Cannuck1964, for the modification to the .htaccess file.

Added at the end of the .htaccess which is directly after all the RewriteRule stuff

& (I believe this is still part of)

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

# Eliminates duplicate home page i.e.: www.domain.com/index.php and www.domain.com appear as duplicate home page 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://www.put_your_domain_here.com/ [R=301,L]

Tom, hopefully the above will help you (and anyone else).

If your store works and includes/filenames.php has this: define('FILENAME_DEFAULT', 'index.php'); -I'll bet it does! Then it needs no reference to "catalog" or any directory at this point, just add define('FILENAME_HOME', '/'); to the list.

 

Thanks! Worked great. Had no problems with the site. Just make sure you get all the cloned pages you have made. Mine were 'testimonials', 'buy with confidence' 'all studios' 'conditions' 'links' etc......

 

Appreciate all the help.

Tom

Link to comment
Share on other sites

  • 1 month later...

Hi! I was JUST about to deal with this issue by changing each file and doing all that extra work, when I came up with this:

 

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

 

So far... from my testing, it works like a charm.

 

I'm so proud -- my first contribution! :)

I find the fun in everything.

Link to comment
Share on other sites

Hi! I was JUST about to deal with this issue by changing each file and doing all that extra work, when I came up with this:

 

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

 

So far... from my testing, it works like a charm.

 

I'm so proud -- my first contribution! :)

 

Thanks for the contrib. I tried this but could only get to work if I defined FILENAME_DEFAULT as follows:

 

  define('FILENAME_DEFAULT', '/');

 

When I left it blank, I took down my site with the following error:

 

 

Error!

 

Unable to determine the page link!

 

Other than this, it seems to work great. Thanks again.

 

Alfredo

Link to comment
Share on other sites

  • 4 weeks later...

If this is any help to anyone reading this , I read the whole thread and went with cannuck1964's suggestion of just changing htaccess.

 

It did the job and was very quick and simple.

 

I have SEO Urls installed

Link to comment
Share on other sites

......just one fly in the ointment :blink: .....My SSL is issued to "mydomain.com" and not "www.mydomain.com" , so i can't use this section of the rewrite -

 

 

# Eliminates www vs. non-www
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ [url="http://www.mydomain.com/$1"]http://www.mydomain.com/$1[/url] [R=permanent,L]

 

 

If I include that it wipes out my SSL

 

Anyone know of a simple adjustment that could be made to that rewrite to take care of non www SSL ?

Link to comment
Share on other sites

Hi,

 

You might try this instead:

 

# Eliminates www vs. non-www
RewriteCond http://mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=permanent,L]

# Eliminates www vs. non-www
RewriteCond https://www\.mydomain\.com
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=permanent,L]

 

This is not tested but should be fine, the removal of the GLOBAL %{HTTP_HOST} should be fine and will just force the two above examples. This is not tested so feel free to do so ;)

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

yes, you can set up the rewrite rules to work how ever you want, by explicitly stating what the rules is, I put above the following:

 

for http://yourdomain.com

 

rewrite it as

 

http://www.yourdomain.com

 

 

for https://www.yourdomain.com

 

rewrite it as

 

https://yourdomain.com

 

you can change this to whatever you like and was given as an example. You are welcome to test it (it is NOT tested) and post back if it work ;)

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

Hi,

 

You might try this instead:

 

# Eliminates www vs. non-www
RewriteCond http://mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=permanent,L]

# Eliminates www vs. non-www
RewriteCond https://www\.mydomain\.com
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=permanent,L]

 

This is not tested but should be fine, the removal of the GLOBAL %{HTTP_HOST} should be fine and will just force the two above examples. This is not tested so feel free to do so ;)

 

cheers,

Peter M

 

 

Thanks Peter , I gave that a try and got an internal server error (500)

Link to comment
Share on other sites

I will have alook as I am sure it is something to do in the syntax, here is a good reference to mod-rewrite if you are interested in doing some reading

 

http://www.webforgers.net/mod-rewrite/

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

You can try this :

 

# Eliminates www vs. non-www
RewriteCond ^http://mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=permanent,L]

# Eliminates www vs. non-www
RewriteCond ^https://www\.mydomain\.com
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=permanent,L]

 

I have what I needed for the mod rewrite so did not look into more changes, I would suggest to you though, that you pick your site to either have the www or no www throughout the site and maintain one way of doing this. Mixing it up maynot be the best idea (I always follow the KISS method).

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

You can try this :

 

# Eliminates www vs. non-www
RewriteCond ^http://mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=permanent,L]

# Eliminates www vs. non-www
RewriteCond ^https://www\.mydomain\.com
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=permanent,L]

 

cheers,

Peter M

 

 

Thanks for ypur help peter , I still get the same error with that. I'm not too worried about the SSL pages being non-www. I was more concerned with the index.php problem which your htaccess rewrite rule fixed very nicely. :thumbsup:

 

Cheers

Link to comment
Share on other sites

  • 2 months later...
Thanks for ypur help peter , I still get the same error with that. I'm not too worried about the SSL pages being non-www. I was more concerned with the index.php problem which your htaccess rewrite rule fixed very nicely. :thumbsup:

 

Cheers

 

I have a question here. Sorry late night last night and brain not functioning well this morning.

 

I would like to have my entire site display as www.toptiara.com regardless of whether it is http or https

 

My SSL is issued to toptiara.com (no www)

 

As such, to keep things simple, I thought it simpler to have everything just as http://toptiara.com, so I updated both my configs to point here

 

It seems with this added to my htaccess, I can fix this though, but I am confused as to how I do it.

 

As I said, at the moment, everything is going to http://toptiara.com and when SSL is used https://toptiara.com. If I want to change this to have everything showing as http://www.toptiara.com or https://www.toptiara.com, do I change the htaccess fil to redirect or do I change the config files to be www?

 

Also, I want to have the redirect in place to stop the engines referencing both the site root and the index.php files for SEO purposes.

 

As I said, tired this am and would appreciate some assistance :)

 

Thanks

Hand made jewellery and tiaras on our website

 

Please bear with me. Im an osC noobie!

Link to comment
Share on other sites

I would like to have my entire site display as www.toptiara.com regardless of whether it is http or https

 

My SSL is issued to toptiara.com (no www)

 

If your SSL is issued without the www then you will need to have the certificate reissued with the www, they are different. Some certificate suppliers will allow this, check with them or it might say how to do it in the email they sent you when you got the cert.

 

 

Also, I want to have the redirect in place to stop the engines referencing both the site root and the index.php files for SEO purposes.

 

See page #1 of this thread. :thumbsup:

Link to comment
Share on other sites

If your SSL is issued without the www then you will need to have the certificate reissued with the www, they are different. Some certificate suppliers will allow this, check with them or it might say how to do it in the email they sent you when you got the cert.

See page #1 of this thread. :thumbsup:

 

Ah ok. So unless I go through getting the certificate re-issued, I just leave everything as it is with no need to do a redirect as all my pages are http://toptiara.com or https://toptiara.com as per the config files?

 

I'm adding the redirect to get rid of the index.php :) Thanks

Hand made jewellery and tiaras on our website

 

Please bear with me. Im an osC noobie!

Link to comment
Share on other sites

Ah ok. So unless I go through getting the certificate re-issued, I just leave everything as it is with no need to do a redirect as all my pages are http://toptiara.com or https://toptiara.com as per the config files?

 

I'm adding the redirect to get rid of the index.php :) Thanks

 

You should set up your config.php files to be without the www OR reissue the certificate.

 

 

*AND*

 

add this to your .htaccess file (but in reverse because this redirects everything to include the www even if someone does not type it in)

 

rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

 

I am not playing with my site so try and reverse it and see if it works.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...