Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Redirecting URL Not Working on Store URLs (.htaccess)


mharmon

Recommended Posts

I am running a website that I have changed the URL of.  I have added the following code to the .htaccess file in my root folder:

RewriteCond %{HTTP_HOST} ^www.oldwebsite.com
RewriteRule ^(.*) http://www.newwebsite.com/$1 [R=301,L] 
 

This works perfectly for ALL pages outside of OSCommerce.  Any OSCommerce page is not being forwarded.  Is there an .htaccess file within OSC that is overwriting my code above?

Thanks,

Michael

 

 

Link to comment
Share on other sites

This .htaccess is in the root of your OLD website, right? And you have RewriteEngine On? Just for safety, I would make the www optional, in case any incoming links are without it:
 

RewriteEngine On

RewriteCond %{HTTP_HOST}  ^(www\.)?oldwebsite\.com  [NC]

RewriteRule  ^(.*)$  http://www.newwebsite.com/$1  [R=301,L]

That ought to work if this is on your old site's root. Is your old osC installation in the root or in /catalog (where it should be)? You'll have to inspect your .htaccess file to make sure you don't have anything before this that's catching your osC addresses. And obviously, on your new site you have nothing that's redirecting back to the old site, or anything crazy like that.

Is your new site on the same server as the old one (the new one is an "add-on domain" under the same account)? Or are they on different machines? If it's an add-on domain, that could complicate matters as the new site will have its own root.

Link to comment
Share on other sites

Thank you for the reply.  Here is a little more information.  There is an .htaccess file in the directory /shop (where I have OSCommerce installed)  It seems to be causing the problem.  It's overriding my command above which works anywhere on the website EXCEPT for any OSCommerce page.  This is what is in the .htaccess file in the /shop directory.  

RewriteEngine On
RewriteBase /shop/
RewriteRule ^enclosures-enclosure-guidelines-c-229_675.html$ /resources#nema-guidelines [L,R=301,NE]
#RewriteRule ^category/(.*)$ index.php?$cPath=$2
RewriteRule ^mc/(.*)$ mc.php?keywords=$1
RewriteRule ^(.*)-c-(.*)-p-(.*)$ product_info.php?cPath=$2&products_id=$3&%{QUERY_STRING}
RewriteRule ^(.*)-p-(.*)$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*)$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c2-(.*)$ index2.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*)-p-(.*).html$ product_info.php?cPath=$2&products_id=$3&%{QUERY_STRING}
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-(.*).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-(.*).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-(.*).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-i-(.*).html$ information.php?info_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
 
 
Link to comment
Share on other sites

WHERE is this one running? Old server or new? The only reason I can think of that your old server is not redirecting to the new server, is that your shop URLs are coming in on oldwebsite.com (not www.oldwebsite.com) and thus not being caught by your RewriteCond given in the first post. My change  (www\.)?  should take care of that. Now, how about the root .htaccess on your new site? Does it have anything blocking /shop, or even redirecting back to the old site? And your new site has the same directory structure as the old one? What happens when you send a URL to the old shop? Do you get any error messages?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...