Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

.htaccess issue 301 redirects


Guest

Recommended Posts

Posted

I built our test site using multiple SEO URL rewrite contributions testing them. I did 301 redirects for all of them as they were installed and uninstalled. In 3 weeks Google was at the test site 12,000 times and Yahoo 8,000 with about 75 uniques a day. I don't want to loose that.

 

The testing is almost done so it is all moved over the the "real" domain and I have been doing the 301 redirects to reflect the change. It is a very long .htaccess file and it all works except for 1 line which is the main page.

 

If I add;

 

redirect 301 /index.php http://www.mydomain.com

 

it redirects and ALL the other 700 + redirects work

 

If I add;

 

redirect 301 / http://www.mydomain.com

 

it breaks ALL the redirects by removing the / between the domain and the page url.

 

It was the first line of the redirect section of the .htaccess file.

 

I am good to go and all the pages redirect except for the main page which is not good. Any ideas on how to make it work without messing up all the other redirects. I can't do a simple redirect as we changes the extensions (.html and .php) , changed the product names, product numbers, category names and numbers, etc.

 

 

Thanks

Posted
I built our test site using multiple SEO URL rewrite contributions testing them. I did 301 redirects for all of them as they were installed and uninstalled. In 3 weeks Google was at the test site 12,000 times and Yahoo 8,000 with about 75 uniques a day. I don't want to loose that.

 

The testing is almost done so it is all moved over the the "real" domain and I have been doing the 301 redirects to reflect the change. It is a very long .htaccess file and it all works except for 1 line which is the main page.

 

If I add;

 

redirect 301 /index.php http://www.mydomain.com

 

it redirects and ALL the other 700 + redirects work

 

If I add;

 

redirect 301 / http://www.mydomain.com

 

it breaks ALL the redirects by removing the / between the domain and the page url.

 

It was the first line of the redirect section of the .htaccess file.

 

I am good to go and all the pages redirect except for the main page which is not good. Any ideas on how to make it work without messing up all the other redirects. I can't do a simple redirect as we changes the extensions (.html and .php) , changed the product names, product numbers, category names and numbers, etc.

Thanks

 

RewriteRules make my head explode .. but try the following: -

 

Obviously don't repeat the top two lines elsewhere

 

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.mydomain.com/$1 [L,R=301]

Posted

Works perfectly, thanks FWR. :) I checked on 12 urls and all worked as they should.

 

It was making my head explode also. One more redirect section to do and all will be done .... hopefully.

Posted

<deleted>Some guaralous diatribe</deleted>

 

Glad it worked for you.

Posted

www.olddomain/ directs to www.newdomain/

www.olddomain/index.php directs to www.newdomain/

www.olddomain/category-c-28.html directs to www.newdomain/manufactuer-m-2.html

www.olddomain/product-p-45.html directs to www.newdomain/product-p-2.html

www.olddomain/privacy.php directs to www.newdomain/privacy.html

 

etc ....

 

 

All works :)

Posted
www.olddomain/ directs to www.newdomain/

www.olddomain/index.php directs to www.newdomain/

www.olddomain/category-c-28.html directs to www.newdomain/manufactuer-m-2.html

www.olddomain/product-p-45.html directs to www.newdomain/product-p-2.html

www.olddomain/privacy.php directs to www.newdomain/privacy.html

 

etc ....

All works :)

 

Keep an eye on https because I think you may need a contrasting rule for that .. depending on cert setup e.g. https://www. or https://

Posted
Keep an eye on https because I think you may need a contrasting rule for that .. depending on cert setup e.g. https://www. or https://

 

Since it was a test site there was no https on it. Although the pages were indexed I did not worry about those redirections and just did the http ones.

 

I could redirect the urls that should have been https to a new https but that seems pointless. Redirecting those pages to the main page of the site does not seem pointless though.

 

But there was always a robots.txt file on the site to ignore those files so I am not sure they were even indexed. I should take a look and see just to make sure.

Posted

Hello, if someone can help me.

 

I'm trying to redirect a domain to www using this in htaccess

 

Options +FollowSymlinks

RewriteEngine on

rewritecond %{http_host} ^domain.com [nc]

rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

 

I installed oscommerce in another folder called shop. http://domain.com/shop

 

The redirects are working but I keep on getting the error page cannot be found when trying to access the admin page: http://domain.com/shop/admin

 

If I removed the codes on the root's htaccess, the http://domain.com/shop/admin

will work.

 

Thank you.

Posted
Hello, if someone can help me.

 

I'm trying to redirect a domain to www using this in htaccess

 

Options +FollowSymlinks

RewriteEngine on

rewritecond %{http_host} ^domain.com [nc]

rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

 

I installed oscommerce in another folder called shop. http://domain.com/shop

 

The redirects are working but I keep on getting the error page cannot be found when trying to access the admin page: http://domain.com/shop/admin

 

If I removed the codes on the root's htaccess, the http://domain.com/shop/admin

will work.

 

Thank you.

 

Well that rewrite rule is saying

 

If condition is http://mysite.com <no www>

Rewrite with a 301 header to http://www.mysite.com

 

Therefore http://domain.com/shop/admin can't work as it has no www.

Posted
Thanks FWR Media, what do you suggest I should do in order to make the admin work with WWW?

 

Well presuming you have no SSL cert installed the first 4 lines of

 

catalog/admin/includes/configure.php should be ..

 

  define('HTTP_SERVER', 'http://www.mysite.com');
 define('HTTP_CATALOG_SERVER', 'http://www.mysite.com');
 define('HTTPS_CATALOG_SERVER', '');
 define('ENABLE_SSL_CATALOG', 'false');

Posted

thank you FWR, it worked!

 

Well presuming you have no SSL cert installed the first 4 lines of

 

catalog/admin/includes/configure.php should be ..

 

  define('HTTP_SERVER', 'http://www.mysite.com');
 define('HTTP_CATALOG_SERVER', 'http://www.mysite.com');
 define('HTTPS_CATALOG_SERVER', '');
 define('ENABLE_SSL_CATALOG', 'false');

  • 2 years later...
Posted

I have a redirect question as well.

my shop is built in www.domain.com/catalog/index.php instead of the root, we have a splash page (an index.html) in the root that redirects to the index.php in the catalog folder.

Now this is not good for google searches i have heard so how do we redirect.

in the .htaccess file?

 

i have tried this:

redirect 301 /catalog/index.php http://www.domain.com

but that does not seem to work.

 

do i need to try a rewrite like this:

 

# Redirect index.php to domain.com

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/

RewriteRule ^index\.php$ http://www.domain.com [R=301,L]

 

thanks for the help

Archived

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

×
×
  • Create New...