Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Archived

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

RAC

Linking "Index of /" to shop

Recommended Posts

Hello all

 

I am running bs Edge and am trying to figure out how to link my “index of /” page to my shop.

 

Currently I have an index,hlml in the public_html folder that is redirecting to a simple under construction page.

Also in the public_html folder are a couple of files from my host, a favicon.ico file and my catalog folder, and finally a .htaccess file, (which has two redirects) :

 

RewriteCond  %{HTTPS} off   [OR]

RewriteCond  %{HTTP_HOST}  !^www\.  [NC]

RewriteRule  ^(.*)$  https://www.retro-antiques-curios.co.uk/$1  [R=301,L]

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php?/$1 [L]

 

I do not intend to open a blog, or any other section of the website.

 

Obviously when I remove the under construction index.html my above domain address lands on the index of / section, which as you know just lists the above files.

 

Ideally I would like have anyone who types in www. (or just) retro-antiquer-curios.co.uk to go to my shop, is this possible?

 

What other options do I have from this position? Maybe an “enter” page?

 

Any suggestions will be much appreciated.

 

Regards Shaun

Share this post


Link to post
Share on other sites

Hi,

depends  where and how your site is hosted, normally you can direct the domain to any subfolder of  public_html by using your providers tools for domain settings.

The .htaccess file has to be moved to the subfolder  (catalog) or merged if there is already one and rewrite base would be

RewriteBase /

then.

Best regards

Christoph

Share this post


Link to post
Share on other sites

Your RewriteEngine On statement has to come before the other Rewrite* statements.

Is your store installed in /catalog? If so, it is possible to have a visitor to / (just the domain name given) jumped to /catalog:

RewriteCond  %{REQUEST_URI}  !^/catalog  [NC]
	RewriteRule  ^(.*)$  /catalog/$1 

This is just before the first REQUEST_FILENAME statement.

By the way, it is a security hazard to allow visitors to see an auto-generated list of files and subdirectories in a directory. If your host doesn't allow Options -Indexes, you should put an empty index.html file in any directory that doesn't already have an index.* file.

Share this post


Link to post
Share on other sites

Hello Christoph

I have been in discussions with my host for the last two days but they, so far, have been unable to sort it! I will try again with the info you  have provided.

Also, you have forgotten Christoph, I do not know what I am doing, so explanations need to be simpler!

I understand that the .htaccess file will need to be moved or merged to my catalog, but Rewritebase!!

 

Regards Shaun

Share this post


Link to post
Share on other sites

Hello Rainer

 

I have moved the RewriteEngine On,  to the top of my .htaccess file as suggested.

The code you posted gave an internal server error.

 

Shaun

Share this post


Link to post
Share on other sites

Rainer?

Try first without the RewriteBase statement. One thing at a time.

If you're getting errors, show your entire .htaccess file (with any sensitive information such as account name ***'d out). Also tell us where this .htaccess file is, and the content of any other .htaccess files you have in the root (/.htaccess) or catalog.

Share this post


Link to post
Share on other sites

My apologies @MrPhil  @raiwa, I hope that was not a too big an insult, for either of you!

 

My old .htaccess file from my public_html folder was

 

RewriteEngine On

RewriteCond  %{HTTPS} off   [OR]

RewriteCond  %{HTTP_HOST}  !^www\.  [NC]

RewriteRule  ^(.*)$  https://www.retro-antiques-curios.co.uk/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php?/$1 [L]

 

This I have now merged with the catalog ,htaccess, as suggested.

 

I have also have in this folder an index.html under construction redirect.

 

This is my catalog ,htaccess

 

# $Id$

#

# This is used with Apache WebServers

#

# For this to work, you must include the parameter 'Options' to

# the AllowOverride configuration

#

# Example:

#

# <Directory "/usr/local/apache/htdocs">

#   AllowOverride Options

# </Directory>

#

# 'All' with also work. (This configuration is in the

# apache/conf/httpd.conf file)

 

# The following makes adjustments to the SSL protocol for Internet

# Explorer browsers

 

#<IfModule mod_setenvif.c>

#  <IfDefine SSL>

#    SetEnvIf User-Agent ".*MSIE.*" \

#             nokeepalive ssl-unclean-shutdown \

#             downgrade-1.0 force-response-1.0

#  </IfDefine>

#</IfModule>

 

# If Search Engine Friendly URLs do not work, try enabling the

# following Apache configuration parameter

 

# AcceptPathInfo On

 

# Fix certain PHP values

# (commented out by default to prevent errors occuring on certain

# servers)

 

# php_value session.use_trans_sid 0

# php_value register_globals 1

 

RewriteEngine On

RewriteBase /

RewriteCond  %{HTTPS} off   [OR]

RewriteCond  %{HTTP_HOST}  !^www\.  [NC]

RewriteRule  ^(.*)$  https://www.retro-antiques-curios.co.uk/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php?/$1 [L

 

<IfModule mod_headers.c>

  Header unset ETag

</IfModule>

FileETag None

 

## EXPIRES CACHING ##

## https://gtmetrix.com/leverage-browser-caching.html ##

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/jpg "access plus 1 year"

ExpiresByType image/jpeg "access plus 1 year"

ExpiresByType image/gif "access plus 1 year"

ExpiresByType image/png "access plus 1 year"

ExpiresByType text/css "access plus 1 month"

ExpiresByType application/pdf "access plus 1 month"

ExpiresByType text/x-javascript "access plus 1 month"

ExpiresByType application/x-shockwave-flash "access plus 1 month"

ExpiresByType image/x-icon "access plus 1 year"

ExpiresByType application/javascript "access plus 1 year"

ExpiresDefault "access plus 2 days"

</IfModule>

## EXPIRES CACHING ##

 

#Options –Indexes

 

 

This is the error message I get on both shop and admin side, with and without the RewriteBase / line.

 

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@retro-antiques-curios.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Hello Rainer

 

I have moved the RewriteEngine On,  to the top of my .htaccess file as suggested.

The code you posted gave an internal server error.

 

Shaun

Share this post


Link to post
Share on other sites

Hi,

in which way is your domain now pointing to the subfolder /catalog ?

The rewrite part of my .htaccess starts this way (with examples for base):

<IfModule mod_rewrite.c>
  RewriteEngine On

  # RewriteBase instructions
  # Change RewriteBase dependent on how your shop is accessed as below.
  # http://www.mysite.com = RewriteBase /
  # http://www.mysite.com/catalog/ = RewriteBase /catalog/ 
  # http://www.mysite.com/catalog/shop/ = RewriteBase /catalog/shop/

  # Change RewriteBase using the instructions above  
  RewriteBase /

and ends like this:

</IfModule>
 

Best regards

Christoph

 

Share this post


Link to post
Share on other sites

I would not try merging root and catalog .htaccess files. You seem to be messing up something doing that. In the root (/.htaccess), just have common sitewide stuff, like forcing https and www, IP blocks, cache settings, etc. In an application's root directory (/catalog/.htaccess) you put stuff particular to that application (osC in this case), such as the REQUEST_FILENAME rewrites to /index.php. Incidentally, be careful with that last one... it says to send invalid files or directories to /index.php, which is in the root, not the store catalog. It's a hard coded path to root.

Keeping the site and store .htaccess files separate makes it easier to upgrade (or replace) your store without messing up other applications. It's also why you put each major application (such as a store) in its own directory tree (like /catalog/), rather than loading it into root. Eventually you will want to install a blog, or a picture gallery, or some other application; and it's so much easier if everything is already nicely compartmentalized. Servers are supposed to read and process /.htaccess and then all .htaccess files down the chain, overriding earlier settings, although I have seen at least one host who skips over .htaccess files and jumps directly to the target directory!

As to why you're getting an Internal Server Error (500), the only thing I see is FileETag None, which might not be valid if your Apache server is a bit backlevel. Try commenting it out (#) and see if the error goes away. If it does, try moving it up inside the mod_headers.c group. Are you on a non-Apache server by any chance?

Share this post


Link to post
Share on other sites

Thank you both the problem is now sorted.

For some reason the code @MrPhil posted in your first post now works! I don't know what I done wrong the first time as to why it did not work, fat fingers I expect. You are a STAR, (don't worry, I won't offer to kiss you).

What I done was to put everything back to what it was at the start of this topic, then added your code then hey presto, my domain now points to my shop.

16 hours ago, MrPhil said:

Incidentally, be careful with that last one... it says to send invalid files or directories to /index.php, which is in the root, not the store catalog. It's a hard coded path to root.

What do you suggest I do with this? does this need to be removed/adjusted? or should I just leave it as all seems to be working fine?

Regards Shaun

Share this post


Link to post
Share on other sites

You're saying "go to /index.php if the requested directory or file doesn't exist".  That's an absolute address, which will be a problem if your store is in, say, /catalog (/catalog/index.php). If you have an index.php in root, and it does what you want, that's fine. I was just warning that if there is no /index.php, and you give an invalid address, bad things will happen.

Share this post


Link to post
Share on other sites

Hello Phil

The store is in catalog, although my catalog is called RAC_Shop. 

Up until a few days ago index.php was in the address bar, that is where the last three lines of the ,htaccess redirect come in, now there is no index.php in the address bar as below.

Then - retro-antiques-curios.co.uk/RAC_Shop/index.php/--- 

Now - retro-antiques-curios.co.uk/RAC_Shop/---

I have commented out this index.php line, all still seems to work fine, I will keep an eye on it.

All I need to do now is sort out the product information in the address bar, I don't think the SEO included in Edge is configured correctly as the address for a product is 

https://www.retro-antiques-curios.co.uk/RAC_Shop/product_info.php?cPath=33&products_id=76

instead of 

https://www.retro-antiques-curios.co.uk/RAC_Shop/PRODUCT ACTUAL NAME.

I think I will start a new thread for this.

 

Regards Shaun

Share this post


Link to post
Share on other sites
Have a look at the following code 
 
<IfModule mod_expires.c>
 
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
 
</IfModule>
 
 

Share this post


Link to post
Share on other sites

×