.httaccess 301 redirect subdomain with path wildcards - .htaccess

I need to 301 redirect URL's I was using on my old website/platform to my new website on Shopify.
Old url structure:
https://shop.olddomain.com/path/name-of-page
What I would like to have is a wildcard for http/https, because the platform changed my website from insecure to secure back when Google started ranking based on that.
I would also need a wildcard for /path/name-of-page, because I have hundreds of URL's with that structure and I'm not trying to map each of those URL's to the new URL's. Basically, my goal is to make sure those old URL's don't go to a dead end 404, and are redirected to the new website homepage.
So http/https://shop.olddomain.com/* should redirect to https://newdomain.com

In your .htaccess for shop.olddomain.com place
Redirect 301 /shopoldpath https://newdomain.com

Related

Need help redirecting one website URL to another with apache2 and .htaccess

I have two domains - https://hosting.opensimcity.org, and http://paradigm.pocketmud.com and I want to redirect the latter to the former. That is, when someone connects to http://paradigm.pocketmud.com I want it to redirect to https://hosting.opensimcity.org/paradigm
Any tips on doing this in my .htaccess file?
Just try the following htaccess redirect code:
Redirect 301 / https://hosting.opensimcity.org/paradigm
This 301 redirect response notifies the search engines that the page has moved permanently from the old URL to the new URL. The search engines also transfer the old URL page rank to the new URL.

Redirect domain to subfolder with some specific pages fallback

I need to change website domain from www.domain.com to www.newdomain.com/en but I also need to specify some pages from old website to new website like www.domain.com/page to www.newdomain.com/en/subfolder/subfolder/page.
Last thing should be great keeping one subfolder path of old website free of redirect like www.domain.com/admin in order to keep backend access to old website.
What would you suggest me to add to old site htaccess file in order to achieve that with a sort of fallback mechanism for specifc pages and whole domain to subdirectory?
Thank you
You can add the following 301 redirect to your oldsite/htaccess :
Redirect 301 / http://newdomain.com/en/subfolder/subfolder/
This will redirect all requests from your old site to the subfolder in your new site
Edit : as per your comment,
to exclude a specific path from the redirection, you may use RedirectMatch
RedirectMatch 301 ^/((?!page1|page2).*) http://newdomain.com/en/subfolder/subfolder/$1
This will not redirect /page1 or /page2 .

Moving VERY old website to New Domain

I have been creating a new website for a company and would like some advice on writing a rewrite file.
I obviously would like to keep our current rankings and transfer them to the new site and i am just wanting to make sure I am doing it correctly.
Would a standard 301 redirect with old links to new links work if I also write a rewrite to the home page?
This isn't my area and any help would be great.
Justine
This Redirect htaccess code below in an htaccess file in the old site's folder would redirect all old site pages and posts to identical matching pages and posts with the same identical structure on the new site/domain.
RedirectMatch 301 ^/$ http://www.newdomain.com/$1
For some web hosts you need to include the folder name where the website is physically installed. olddomain.com would be the name of the folder and not the URL|URI name.
RedirectMatch 301 ^/olddomain.com$ http://www.newdomain.com/$1

Trouble 301 redirecting pages from old Wix site to new site

My client's original site was built on Wix, and I have designed and built a new one on a new server.
I'm trying to 301 redirect some pages from the old site to their counterparts on the new one, and it doesn't seem to want to work properly, as each old URL simply goes straight to the home page.
Example case:
old URL: example.com/#!clients/c1pen
new URL: example.com/stay-with-us
I have the redirect set out like so in .htaccess:
Redirect 301 /#!clients/c1pen /stay-with-us
Can anyone shed some light on this for me?
Hash-location (http://someurl/#hash-location) typically adresses an anchor in a html page and is not visible to the server rewrite rules. Consequently the matcher #!clients/c1pen does never match. See 'hash' url rewrite in .htaccess

htaccess Redirect URL of Subdirectories managed through CMS

All the urls of our site are written www.mydomain.com/sub1/cms/pagename
Through the CMS we can specify pagename
sub1 and cms are not actually directories on the server.
We need to change the pagenames to be more SEO friendly, but we still want any traffic to the old pagename to direct to the new one.
I have tried making an .htaccess file specifying:
Redirect 301 /sub1/cms/oldpagename mydomain.com/sub1/cms/newpagename
but it does not work.
I have been successful with:
Redirect 301 /oldpagename mydomain.com/sub1/cms/newpagename
Can this be done somehow through .htaccess?
First, make sure your 301 redirect rules for redirect use a full url including the http:// portion.
Redirect 301 /sub1/cms/oldpagename http://mydomain.com/sub1/cms/newpagename
Second, it sounds to me like your CMS has put a rewrite rule in place to handle the /sub1/cms/pagename style urls. If this rule comes before your redirect, your redirect will never get triggered. Try moving your redirect to the top of the .htaccess file.

Resources