How can I redirect Magento Store URL's to WooCommerce Store URL's? - .htaccess

I am trying to make a 301 redirect from a Magento Store URL to a Woocommerce Store URL. Here is what I used in my .htaccess file:
Redirect 301 /catalog/index.php/customer/account/ /my-account/
That should redirect the Magento Account page to the WooCommerce My Account page. However, when you try to go to /catalog/index.php/customer/account/ on my new site it redirects you to /shop/customer/account/ (which does not exist on my site).
Again, I have another redirect in my .htaccess file:
Redirect 301 /catalog/index.php/greeting-cards.html /product-category/greeting-cards/
And again, /catalog/index.php/greeting-cards.html is redirecting to /shop/greeting-cards.html instead of the URL I specified in my .htaccess file. All the URL's with the base of /catalog/ are redirecting only their base to /shop/. My .htaccess file is working because I have another redirect in there:
Redirect 301 /about_us.php /about-us/
And that redirect works.
There must be some rule from WordPress or WooCommerce that rewrites /catalog/ to /shop/. So how do I redirect a Magento Store URL to a WooCommerce store URL?
I would appreciate any help you can give me. Thanks!
I am running:
WordPress 3.8.3
WooCommerce 2.1.5
Site URL: http://www.thepottersheart.com/
Full .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect 301 /about_us.php /about-us/
Redirect 301 /catalog/ /shop/
Redirect 301 /contact_us.php /contact-us/
Redirect 301 /calendar.php /calendar/
Redirect 301 /what_people_say.php /testimonials/
Redirect 301 /where_we_go.php /where-we-go/
Redirect 301 /catalog/index.php /shop/
Redirect 301 /catalog/index.php/customer/account/ /my-account/
Redirect 301 /catalog/index.php/checkout/cart/ /cart/
Redirect 301 /catalog/index.php/checkout/onepage/ /checkout/
Redirect 301 /catalog/index.php/customer/account/login/ /my-account/
Redirect 301 /catalog/index.php/grace-dvd-and-pottery.html /product-category/grace-dvd/
Redirect 301 /catalog/index.php/greeting-cards.html /product-category/greeting-cards/
Redirect 301 /catalog/index.php/worship-flags-praise-flags.html /product-category/worship-flags-praise-flags/

Related

301 Redirect subpages to new main page

Hi I am new to redirects.
I can get the basic Redirect 301 /page1/ https://example.com/newpage/ redirects to work fine.
I am having an issue with removing a parent page and all of it's child pages and redirecting everything to a new parent page.
The main redirect works:
Redirect 301 /eye-can-hear/ htps://example.com/procedures-services/
But trying to redirect the sub pages
Redirect 301 /eye-can-hear/hearing-services/ https://example.com/procedures-services/
Is redirecting to /procedures-services/hearing-services/ which doesn't exist.
Here is what the .htaccess file looks like, the 2-7 do not redirect properly:
Redirect 301 /eye-can-hear/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/hearing-services/ https://example.com/procedures-services
Redirect 301 /eye-can-hear/hearing-aids/ https://example.com/procedures-services
Redirect 301 /eye-can-hear/self-test-your-hearing/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/schedule-your-hearing-evaluation/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/financing/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/dual-sensory-wellness/ https://example.com/procedures-services/
Redirect 301 /about-costello-eye-physicians/community-involvement/ https://example.com/about-costello-eye-physicians/in-the-news/
There are some more redirect's but I can only post 7 links. Further down the .htaccess file after some iThemes security stuff is this:
# Stop wordpress username enumeration vulnerability
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^/?author=([0-9]*)
RewriteRule ^(.*)$ https://example.com/? [L,R=301]
and also this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Change this lines (2-7) that do not redirect properly to this rewrite:
RewriteEngine On
RewriteRule ^eye-can-hear\/(.*)$ https://example.com/procedures-services [R=301,L]
It's redirect all subpages of /eye-can-hear/* to https://example.com/procedures-services
This line of code worked for me in the .htaccess file:
RedirectMatch 301 /eye-can-hear/(.*) https://example.com/procedures-services
It redirects the page https://example.com/eye-can-hear/ and its subpages to the URL https://example.com/procedures-services
(Answer after two years, but maybe it helps someone)
In the htaccess file, you should put this redirection after all other redirections of subpages:
Redirect 301 /eye-can-hear/ https://example.com/procedures-services/
Your htaccess should be like this:
Redirect 301 /eye-can-hear/hearing-services/ https://example.com/procedures-services
Redirect 301 /eye-can-hear/hearing-aids/ https://example.com/procedures-services
Redirect 301 /eye-can-hear/self-test-your-hearing/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/schedule-your-hearing-evaluation/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/financing/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/dual-sensory-wellness/ https://example.com/procedures-services/
Redirect 301 /eye-can-hear/ https://example.com/procedures-services/

htaccess 301 redirect with question mark

I have list of URL (600 approximately) that needs to be redirected, few URL are:
Redirect 301 /assets?/elfinder1?/elfinder.html http://www.example.com/swiftkanban/
Redirect 301 /backup?/elfinder?/elfinder.html http://www.example.com/swiftkanban/
Redirect 301 /blog?/xmlrpc.php http://www.example.com/blog/
Redirect 301 /blog.feed?type=rss http://www.example.com/blog/
Redirect 301 /m?/ http://www.example.com/swiftkanban/
Redirect 301 /m/ http://www.example.com/swiftkanban/
Redirect 301 /mobile?/ http://www.example.com/swiftkanban/
Redirect 301 /mobile/ http://www.example.com/swiftkanban/
Redirect 301 /SgjRY?/blog?/16-david-blog?/63-who-owns-kanban.html http://www.example.com/blog/who-owns-kanban/
Redirect 301 /support?/about.html http://www.example.com/about-us/
Redirect 301 /support?/about_us http://www.example.com/about-us/
Redirect 301 /support?/aboutus http://www.example.com/about-us/
Redirect 301 /support?/company http://www.example.com/about-us/the-team/
Redirect 301 /support?/contact.html http://www.example.com/contact-us/
Redirect 301 /support?/contact_us http://www.example.com/contact-us/
Redirect 301 /support?/contactus http://www.example.com/contact-us/
The problem is, I cannot do wildcard redirect, and this redirect rule does not work, I tried escaping the question mark using \ but this does not seem to work, can someone point me to the right direction?
Redirect directive cannot match query string. You need to use mod_rewrite based rules and use a RewriteCond directive as example below:
RewriteEngine On
RewriteCond %{THE_REQUEST} /blog\?/xmlrpc\.php [NC]
RewriteRule ^ http://www.example.com/blog/? [L,NE,R=301]
RewriteCond %{THE_REQUEST} /blog\.feed\?type=rss [NC]
RewriteRule ^ http://www.example.com/blog/? [L,NE,R=301]
Trailing ? after /blog/ is for removing pre-existing query string. If you want query string after redirect then remove ? from target URL.
References:
Apache mod_rewrite Introduction
.htaccess tips and tricks

301 Redirect entire site to new site using .htaccess file

Ive got a site siteONE.co.uk that i want to 301 permanent redirect all the pages to another site, siteTWO.co.uk
For this im currently using the this .htaccess file below, but im have to type out a new line for each page i want to rediect even though they are all going to the homepage of siteTWO.co.uk. They are also redirecting incorrectly, instead of siteONE.co.uk/aberdeen going to siteTWO.co.uk its going to siteTWO.co.ukaberdeen (note there is not / between the .co.uk and aberdeen)
Any ideas were im going wrong with this ?
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(http://siteONE\.co\.uk)(:80)? [NC]
RewriteRule ^(.*) http://www.siteONE.co.uk/$1 [R=301,L]
order deny,allow
RewriteEngine on
RewriteRule ^/?$ http://siteTWO.co.uk/ [R=301,L]
redirect 301 / http://siteTWO.co.uk
redirect 301 /aberdeen http://siteTWO.co.uk
redirect 301 /bath http://siteTWO.co.uk
redirect 301 /belfast http://siteTWO.co.uk
redirect 301 /birmingham http://siteTWO.co.uk
redirect 301 /cambridge http://siteTWO.co.uk
redirect 301 /canterbury http://siteTWO.co.uk
redirect 301 /chester http://siteTWO.co.uk
redirect 301 /york http://siteTWO.co.uk
You can get rid of all the code in your .htaccess and use this rule instead:
RewriteEngine on
RewriteRule ^ http://siteTWO.co.uk/? [R=301,L,NE]
Make sure to clear your browser cache before testing this.

htaccess 301 redirect not working with my site

I have rewrite URL via htaccess now I want to redirect that URL to another URL.
Now I want to redirect http://www.domain.com/tag/example-page URL to http://www.domain.com/tag/example
redirect 301 /tag/example-page http://www.domain.com/tag/example
Please help me regarding this issue.
Below is my rewrite rule, which I am using for short URL
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Keep this rule as your very first rule in root .htaccess:
RedirectMatch 301 ^/tag/example-page/?$ /tag/example

HTACCESS url in page REDIRECT

I have a url condo-search.co and it loads a blank page, I want to direct it to condo-search/en/index.php how do i do that using htaccess?
You can add this:
RedirectMatch 301 ^/$ /en/index.php
in your document root's htaccess file. Or if you want it to not externally redirect:
RewriteEngine On
RewriteRule ^$ /en/index.php [L]

Resources