Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Putting index.php in the root


matthew_scullion

Recommended Posts

Posted

I have built a great OScommerce site (I think!) which I'm really happy with apart from one thing.

 

At the moment I have my OScommerce files arranged in the normal way. I have deployed these onto my shared web space, the root folder of which is called HTDOCS. So my directory structure looks like this:

 

htdocs\catalog\index.php

htdocs\catalog\admin

htdocs\catalog\includes

etc…

 

This means that when I want to access my site as an end user, the url I need to type is:

 

http://www.my-domain.com/catalog

 

What I would like to do is have the url simply as

 

http://www.my-domain.com

 

which would mean that my index.php file will need to be in the root, i.e. a directory structure as follows

 

htdocs\index.php

htdocs\admin

htdocs\includes

etc…

 

Is this possible? Can I just move all the files and folders up into my root folder, update a config somewhere and it will work?

 

I have already investigated using re-directs, or a .HTAccess file, neither of which or suitable for me.

 

Many thanks in advance for any help.

 

Regards, Matthew.

Posted

Hi. You would have to put all files and folders in your root not just index.php

Then you must edit your two config files to erase catalog from the url.

Posted

Another way to do this is to create an index.html in your root folder and put this line in it:

 

<meta http-equiv="refresh" content="0;url=https://www.yourdomain.com/catalog/index.php">

 

this will just redirect your customer to the catalog/index.php. This is the way I do it anyway, saves the trouble of installing the whole thing again and it is invisable.

 

Bob

Posted
Another way to do this is to create an index.html in your root folder and put this line in it:

 

<meta http-equiv="refresh" content="0;url=https://www.yourdomain.com/catalog/index.php">

 

this will just redirect your customer to the catalog/index.php. This is the way I do it anyway, saves the trouble of installing the whole thing again and it is invisable.

 

Bob

 

But won't a 0 delay refresh trigger spam filters in most search engines that will reduce your search engine rank? I think a better way if you have access to your .htaccess file would be to use a 301 Redirect in the .htaccess file. A 301 means permanently moved, and search engines don't penalize for this.

 

Just add the following line to your .htaccess file that is in the root directory:

 

Redirect 301 /index.html http://www.mydomain.com/catalog/index.php

 

Of course, change mydomain to your actual domain name.

Posted
But won't a 0 delay refresh trigger spam filters in most search engines that will reduce your search engine rank? I think a better way if you have access to your .htaccess file would be to use a 301 Redirect in the .htaccess file. A 301 means permanently moved, and search engines don't penalize for this.

 

Just add the following line to your .htaccess file that is in the root directory:

 

Redirect 301 /index.html http://www.mydomain.com/catalog/index.php

 

Of course, change mydomain to your actual domain name.

 

Ok that sounds great. Google hits me every 2 days or so and I get another one called web core but those are the only 2 spiders that have found me so far, but I'm not open yet. The tech guys can't seem to get my downloads to complete. My downloads stop after 4 min and 10 sec. So I'm only getting about half of the smaller ones.

Posted
Ok that sounds great. Google hits me every 2 days or so and I get another one called web core but those are the only 2 spiders that have found me so far, but I'm not open yet. The tech guys can't seem to get my downloads to complete. My downloads stop after 4 min and 10 sec. So I'm only getting about half of the smaller ones.

 

well just looked and either that file isn't in the root or I don't have access to it. I should have access I have total access, I deleted a lot of stuff I had in the root and may have deleted it. What all is in that file? Can I just create a new one and put that line in it?

 

My server is MS IIs does it have an .htaccess file?

Posted
well just looked and either that file isn't in the root or I don't have access to it. I should have access I have total access, I deleted a lot of stuff I had in the root and may have deleted it. What all is in that file? Can I just create a new one and put that line in it?

 

My server is MS IIs does it have an .htaccess file?

 

Files with a dot (.) in front of the name are hidden from view for security reasons, but they are there even tho you can't see them. You have to enable special settings in your FTP program to see them, but it's best to leave them hidden on the server side.

 

You can add this code to make them unviewable in a browser if people you don't want to see them do happen to find them:

#Disable .htaccess viewing from browser
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>

 

You can also add the following to block out many common exploits people try to insert in scripts like osC:

# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]

 

These in the 2nd block of code may not work on all server configurations. You can try them, and if it breaks anything, just remove it again and you'll be back where you were, no harm done. If you can't see your .htaccess file, you can just overwrite it with a blank file with the same name to erase it again.

 

I use Apache and Unix, so I don't know how MS IIs work. If it does support .htaccess files, just open a text file in NotePad, put the lines you want in there and save the file as htaccess.txt

 

Then after you upload it, change the name to .htaccess and it will disappear from view, but it will still be there and the .txt extension on your harddrive side will make it easily accessible to you when you want to make other changes.

 

.htaccess files can be used to control many things. If you use the SEF contribs to make short URLs that appear static, you have to add some different stuff to your .htaccess file, for example. You can also use it to tell the browser where to go if for some reason a page is not found or a link is broken instead of the generic "Page Not Found" message - this would be another example. The code for that is

ErrorDocument 404 /http://www.domainURLwhereYouWantItToGo.com

 

If you don't know whether or not you have one, you probably don't, unless your web host put one there for some reason. But usually they don't. You can ask them to be sure. They would also be able to tell you if your setup supports these .htaccess settings.

Posted
Files with a dot (.) in front of the name are hidden from view for security reasons, but they are there even tho you can't see them. You have to enable special settings in your FTP program to see them, but it's best to leave them hidden on the server side.

 

You can add this code to make them unviewable in a browser if people you don't want to see them do happen to find them:

#Disable .htaccess viewing from browser
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>

 

You can also add the following to block out many common exploits people try to insert in scripts like osC:

# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]

 

These in the 2nd block of code may not work on all server configurations. You can try them, and if it breaks anything, just remove it again and you'll be back where you were, no harm done. If you can't see your .htaccess file, you can just overwrite it with a blank file with the same name to erase it again.

 

I use Apache and Unix, so I don't know how MS IIs work. If it does support .htaccess files, just open a text file in NotePad, put the lines you want in there and save the file as htaccess.txt

 

Then after you upload it, change the name to .htaccess and it will disappear from view, but it will still be there and the .txt extension on your harddrive side will make it easily accessible to you when you want to make other changes.

 

.htaccess files can be used to control many things. If you use the SEF contribs to make short URLs that appear static, you have to add some different stuff to your .htaccess file, for example. You can also use it to tell the browser where to go if for some reason a page is not found or a link is broken instead of the generic "Page Not Found" message - this would be another example. The code for that is

ErrorDocument 404 /http://www.domainURLwhereYouWantItToGo.com

 

If you don't know whether or not you have one, you probably don't, unless your web host put one there for some reason. But usually they don't. You can ask them to be sure. They would also be able to tell you if your setup supports these .htaccess settings.

 

I could see the .htaccess file in the catalog folder so I guess I may have deleted it in the root.

 

Well as it happens I'll be moving my site to a Linux Host. My old host made me promises they didn't keep. Told me that I could sell downloadable products with no problem and do it for a set price, under $10 per month. Now I find that they limit my downloads to about 10mb and to get it set up to do more will cost me $299 per month. So I found another host that says they can do what I need, hope they aren't doing a bait and switch too. LOL

 

Thanks for the info I'll probably need it on the new host. ;-) The new host also uses osCommerce so I will be happy if all goes well.

 

Bob

Archived

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

×
×
  • Create New...