SEO not working with MOD Rewrite

Hopefully someone can advise me on an issue with SEO.



I just installed CS-Cart 2.015 for a client on my server. I have an SSL cert available for any site that wishes to use it. The SSL domain is a sub domain of the main site.



Each Website is like a user, so the full URL’s work out something like this:



Client Website: (No SSL)

[url]http://www.mywidgets.com/[/url]



My secured URL

[url]https://secure.MainDomain.com/[/url]



Combined URL:

[url]https://secure.MainDomain.com/mywidgets.com/[/url]



I have the boxes checked for:

[COLOR=“DarkOrchid”]“Enable secure connection at checkout (SSL certificate is required to be installed on your server)”[/COLOR]



and



[COLOR=“DarkOrchid”]“Enable secure connection for authentication, profile and orders pages (SSL certificate is required to be installed on your server)”[/COLOR]



Everything works great switching back and forth between secured, and non-secured URL’s UNTIL I enable SEO.



After that, the non-secured front end works fine, and transfer over to the secured side, but trying to come back over from there results in the following errors:



In Firefox:

“Not Found

The requested URL /index.php was not found on this server.”




In IE:

"The webpage cannot be found

HTTP 404

Most likely causes:

There might be a typing error in the address.

If you clicked on a link, it may be out of date. "





It seems to be an issue with the MOD Rewrite configuration, but I am not proficient with MOD Rewrite.



Any Advice greatly appreciated - Thanks!

Am I the only one with this problem?



I really need to get this resolved before going live.



Thanks.

I guess nobody has the same unique situation you have.? I will take a stab at it and say that it might be because of the directory stated within .htaccess:


```php DirectoryIndex index.html index.php





RewriteEngine on

[COLOR=“Red”]# Some hostings require RewriteBase to be uncommented

Example:

Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be:

RewriteBase /store/cart

RewriteBase /[/COLOR]

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]



RewriteCond %{REQUEST_FILENAME} ./catalog/.

RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_FILENAME}/index.html !-f

RewriteRule . index.php?sef_rewrite=1 [L,QSA]



```



You may be confusing it with different folders?

The SEO function will not work for SSL that is located outside of the rewrite base.



The RewriteBase variable is static to the path set and you are leaving that path when entering SSL in your case. I ran into this with clients wanting to use shared SSL on our servers.

Good to see you around again Scott.



Thanks for reconfirming what I was trying to say. LOL

It’s good to see you again also bud





I did a little playing around with this and with a little rewrite rule hacking was able to get the SSL links working with the SEO addon activated…



First of all



To access shared SSL on a cpanel server it must be addressed to the server hostname similar to as how you are doing this AgentEccks.


https://host1.hostdomain.com/~username



I did the following to get this working



config.local.php setup correctly

```php // Host and directory where software is installed on no-secure server

$config[‘http_host’] = ‘www.mydomain.com’;

$config[‘http_path’] = ‘/cscart’;



// Host and directory where software is installed on secure server

$config[‘https_host’] = ‘host1.hostdomain.com’;

$config[‘https_path’] = ‘/~username/cscart’; ```



Then I changed the .htaccess file to below.


[QUOTE]DirectoryIndex index.html index.php





RewriteEngine on



RewriteBase /



[COLOR=“DarkRed”]RewriteCond %{HTTPS} !=on [/COLOR]

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

[COLOR=“DarkRed”]RewriteRule . cscart/index.php?sef_rewrite=1 [L,QSA][/COLOR]



RewriteCond %{REQUEST_FILENAME} ./catalog/.

RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_FILENAME}/index.html !-f

[COLOR=“darkred”]RewriteRule . cscart/index.php?sef_rewrite=1 [L,QSA] [/COLOR]



[COLOR=“darkred”]RewriteCond %{HTTPS} =on[/COLOR]

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

[COLOR=“darkred”]RewriteRule .* ~username/cscart/index.php?sef_rewrite=1 [L,QSA][/COLOR]



RewriteCond %{REQUEST_FILENAME} ./catalog/.

RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_FILENAME}/index.html !-f

[COLOR=“darkred”]RewriteRule .* ~username/cscart/index.php?sef_rewrite=1 [L,QSA][/COLOR]



[/QUOTE]



Notice that I left the RewriteBase to / even though this cart is in a subdirectory. I instead added the path within RewriteRules



There might be a better way to do it but this does seem to work and might for you as well if you get your paths correct.



Good luck

Thanks Scott! MOD Rewrite is definitely not one of my strong suits, but I figured that it would need to be fixed there.



Your solution worked for the most part but I think there is still something that needs to be tweaked a bit.



My server is not using cPanel, but the setup is similar. The control panel is Ensim Pro which allows an alias for the user which, in this case, is the domain name itself.



So the usual https://host1.hostdomain.com/~username becomes https://host1.hostdomain.com/sitedomain.com/ if you leave off the last trailing slash the URL will default to the ‘~useraccount’ instead.



Since CS-Cart is installed in the main directory I didn’t need any other directories other than the user alias. So my .htaccess files looks similar:



```php DirectoryIndex index.html index.php





RewriteEngine on



RewriteBase /



RewriteCond %{HTTPS} !=on

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]



RewriteCond %{REQUEST_FILENAME} ./catalog/.

RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_FILENAME}/index.html !-f

RewriteRule . index.php?sef_rewrite=1 [L,QSA]



RewriteCond %{HTTPS} =on

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* sitedomain.com/index.php?sef_rewrite=1 [L,QSA]



RewriteCond %{REQUEST_FILENAME} ./catalog/.

RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_FILENAME}/index.html !-f

RewriteRule .* sitedomain.com/index.php?sef_rewrite=1 [L,QSA]



```



With the shared SSL I prefer to use the domain name just because it appears more legitimate - At least the clients domain name is still part of the URL.



With this setup the "Home’ link works:



in CS-Cart it is setup as index.php but shows in the status bar as:


https://secure.maindomain.com/sitedomain.com/



the ‘Catalog’ link works, but mod rewrite does not seem to be applied. In CS-Cart it is setup as


index.php?dispatch=categories.catalog



and shows in the status bar as


https://secure.maindomain.com/sitedomain.com/index.php?dispatch=categories.catalog



Same with ‘My Account’, the link works, but mod rewrite does not seem to be applied. In CS-Cart it is setup as


index.php?dispatch=profiles.update



and shows in the status bar as


https://secure.maindomain.com/sitedomain.com/index.php?dispatch=profiles.update



And the Same with ‘View Cart’, the link works, but mod rewrite does not seem to be applied. In CS-Cart it is setup as


index.php?dispatch=checkout.cart



and shows in the status bar as


https://secure.maindomain.com/sitedomain.com/index.php?dispatch=checkout.cart



However the links to the added ‘Pages’ do not work. the link to the 'About Our Company" page shows in the status bar as


https://secure.maindomain.com/sitedomain.com/about-our-company.html



but returns


"Not Found

The requested URL /index.php was not found on this server."




Same with the ‘Contact Us’ page. Status bar shows


https://secure.maindomain.com/sitedomain.com/contact-us.html



browser returns


"Not Found

The requested URL /index.php was not found on this server."




Got any ideas? If anything is not clear, please let me know.

UPDATE: Thanks to those who helped on this post.



I just upgraded my server, and since there haven’t been any real updates in the past couple of years since Parallels bought Ensim (Linux version), I figured I would go with cPanel.



It was a mess, and I really wouldn’t want to go through another conversion like that, but now it seems that the SEO with MOD Rewrite are both working together with the modified .htaccess code that Scott provided above. (Thanks Scott!) :smiley:



I am not sure why it didn’t work with Ensim, since it is basically doing the same thing, but it does work with cPanel, so it looks like I am good to go now.



I will update this if anything changes.

UPDATE:



Well, here I am again with this SEO/ MOD-rewrite ISSUE…



In the previous post everything was and is working in v2.1.1. However I just installed a brand new v2.1.2 on a brand new hosting account (still the same server), but for some reason it is not working properly again.



Basically, I kept the same building blocks of the previous version, and brought them forward into the new version. So my .htaccess file went from this:


```php DirectoryIndex index.html index.php



RewriteEngine on

Some hostings require RewriteBase to be uncommented

Example:

Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be:

RewriteBase /store/cart

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]





```



to this:


```php DirectoryIndex index.html index.php



RewriteEngine on

Some hostings require RewriteBase to be uncommented

Example:

Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be:

RewriteBase /store/cart

RewriteBase /

[COLOR=“Red”]RewriteCond %{HTTPS} !=on[/COLOR]

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]



[COLOR=“Red”]RewriteCond %{HTTPS} =on

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . ~username/index.php?sef_rewrite=1 [L,QSA]

[/COLOR]

```



It seems that the links in the top menu, and quick links work properly, but the links for the products, do not.



I have tried the box under SEO titled Use single URL for all languages both checked, and unchecked, as well as the Show language in the URL box. Neither one seemed to make any difference.



Any one have any ideas on this?

OK, here’s an interesting wrinkle…



I have the default store demo data loaded into the cart, so I was looking at the Apple eMac G4 Desktop with 17



I then clicked View Cart and was presented with Your cart is empty and the Continue shopping button…



This page is now being displayed on the SSL side. The Continue shopping button has the correct link that includes the username (/~username), and when clicked, takes me back to the Home >> Computers >> Desktops category page back on the non-SSL side…



The interesting part is that now all the links under the categories box have the username in the links - Which they should not at this point - and all get the 404 error page. While all the product links listed under the Desktops category have the correct links and work correctly…



To make this even more interesting, now if I click View Cart which puts me back on the SSL side, all the links in the Categories box now have the correct links which include the username and work correctly in getting me back to the non-SSL side, but the username is still not removed from the links as mentioned above, which means that they are still broken.



FYI - Just prior to this I had cleared the var/cache and var/complied directories completely.

The problem I am experiencing seems to be a bug in versions 2.1.2 and 2.1.3. Versions prior to this work as expected. Also, my belief is that the problem lies within the caching process because the first time trough the site everything seems to work as it should then it breaks after going back and forth between the SSL and non SSL versions.



Apparently no one else is having the same issue that I am, and therefore cannot offer any help, so I have resorted to reinstalling a previous version which brings up another problem.



I can no longer find previous versions within my file area, so I resorted to using a previous version that I had already downloaded (v2.0.15). After the initial install, I ran the upgrade to v2.1.0 with the intention of upgrading to v2.1.1 (the previous version where mod rewrite/ caching was working correctly on my server).



However in the upgrade center I see the following message:


[QUOTE]

Version: 2.1.1 Release date: 09/06/2010 05:13 AM Filesize: 1,126 Kb



This is mostly bug fix release with several minor improvements. See change log for details.



This upgrade is not available for your CS-Cart license. Please contact CS-Cart support team to update your license status.

[/QUOTE]



Why can I not upgrade further? This license was just purchased last month!

Suggest you do as the message advises and contact the helpdesk (CS-Cart support team). No one here can address any licensing issues.

[quote name='AgentEccks' timestamp='1297292695' post='103511']

The problem I am experiencing seems to be a bug in versions 2.1.2 and 2.1.3. Versions prior to this work as expected. Also, my belief is that the problem lies within the caching process because the first time trough the site everything seems to work as it should then it breaks after going back and forth between the SSL and non SSL versions.



Apparently no one else is having the same issue that I am, and therefore cannot offer any help, so I have resorted to reinstalling a previous version…

[/quote]



It has been quite a while since posting on this subject but alas, a new update.



[RECAP]

In my situation, most of my clients use CS-Cart with a shared SSL cert and even though these Websites reside on the same server, the URL's are different. Thanks to S-Combs, I had a mod-rewrite setup that solved the issue with all versions up to 2.1.1. However all versions after that (versions 2.1.2 and 2.1.3 at the time), no longer worked correctly and my belief was that it was due to the caching feature that was introduced in those versions.



I had provided CS-Cart with a great deal of documentaion as to exactly what was hapening, and I have kept most of my clients at the 2.1.1 version hoping that this issue would be resolved in future releases.



[UPDATE]

I have received inquiries from a few of my clients wishing to upgrade to the newest version of CS-Cart, so I have downloaded and installed the v2.2.4 to see if my previous SEO with Shared SSL issues has been been resolved.



For the most part it seems that the problem is now resolved. For every “dispatch” value that was on the home page, I have an SEO name for it setup under the SEO Rules settings (15 in total). For every one of these links going back and forth between the regular site and the shared SSL site works without issue.



i.e.: From the home page, clicking on View Cart ([color=#ff0000]http://www.site-doma…/view-cart.html[/color])



re-directs to

[color=#ff0000] https://secure.SSL-d…/view-cart.html[/color]



From there, clicking on Gift Certificates ([color=#ff0000]https://secure.SSL-d…rtificates.html[/color])



re-directs back to

[color=#ff0000] http://www.site-doma…rtificates.html[/color]



No problems here.



However, when it comes to the actual product links from the shared SSL side there is a slight issue.



It seems that it could be an easy fix but I am not sure where to look. I don't know if it is the mod-rewrite or the SEO add-on script. Since everything else is working correctly, I am leaning toward the SEO add-on script.



I need a bit of help to see if this can be fixed and we'll be good to go.



Here are the details regarding the product links (this install is setup with default data).



Same as above, starting from the home page and clicking on View Cart ([color=#ff0000]http://www.site-doma…/view-cart.html[/color])



Re-directs to

[color=#ff0000] https://secure.SSL-d…/view-cart.html[/color]



From here if I click one of the product links, for this example, I am using Computers ([color=#ff0000]https://secure.SSL-d…/computers.html[/color])



This re-directs to

[color=#ff0000] http://www.site-domain.com/~username/computers.html?sid_customer=b5feb494122e237a2a91f25ca01c2db8[/color]



which results in CS-Carts 404 error page being displayed.



If I remove the [color=#ff0000]/~username[/color] portion of the URL the page will redirect fine ([color=#ff0000]http://www.site-doma…/computers.html[/color]).



So it seems, all that needs to happen is to remove the [color=#ff0000]/~username[/color] portion of the re-direct URL from the product links, but the question is, does this need to be done in the SEO add-on script, or in mod-rewrite?



This install is not in a subfolder, it is directly in the site root.



and the mod-rewrite rule is setup as follows:


```php



RewriteEngine on

Some hostings require RewriteBase to be uncommented

Example:

Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be:

RewriteBase /store/cart


RewriteCond %{HTTPS} !=on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} .*\/catalog\/.*
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteRule . index.php?sef_rewrite=1 [L,QSA]


RewriteCond %{HTTPS} =on
RewriteBase /~username

RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} .*\/catalog\/.*
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteRule . index.php?sef_rewrite=1 [L,QSA]


```

Any help is greatly appreciated.