Redirects for top-level pages work fine, but now I'm looking to redirect sub-pages in a WordPress site to their new respective top level page, but I evidently don't have the correct syntax:
Old page: websiteURL/aboutus/benefits
New page: websiteURL/careers
After trolling through the forums, I tried this option, but no luck:
redirectMatch 301 ^/aboutus/benefits$ http://website.net/careers/
Problem: Rather than re-directing to the new absolute/static URL, the redirect just changes the folder name, so the resulting URL is simply
websiteURL/about-us/benefits.
One more example of a sub-page needing to the redirected to an absolute URL:
Old url: websiteURL/expertise/software-engineering
New url: websiteURL/core-competencies
redirectMatch 301 /expertise.* http://websiteURL/core-competencies
But this doesn't work. The resulting URL is websiteURL/core-competencies/software-engineering
Meaning it changes the folder name, then adds on the page name. No good for what we need.
Related
I have my old website old.com and my new website new.com. I want to create 301 redirects in the .htaccess for some specific pages and some generic 301 redirects as well.
Get parameter redirects:
old.com/a/test?u=blah redirect to new.com/a/test?u=blah
old.com/a/test redirect to new.com/a/test
old.com/a/test.php?u=blah redirect to new.com/a/test?u=blah
As you can see the only thing that changed was the domain name. How can I redirect users to the new domain but also keep their get parameter the same. So regardless of what u=, it forwards the u= parameter to the new URL. Of course if there is no u=, it still redirects to the page (as per second example)
Get parameter without putting get parameter
old.com/a/foo?u=blah redirect to new.com/a/foo
old.com/a/foo redirect to new.com/a/foo
old.com/a/foo.php?u=blah redirect to new.com/a/foo
As you can see, it directs to the new domain but does not carry the u= parameter. Same applies for the second example.
Redirect Directory
old.com/blog redirect to new.com/blog
old.com/blog/23452/how-to-tie-a-tie redirect to new.com/blog
If the site is in the blog directory, regardless of what comes after the blog directory in the URL, it always redirects back to new.com/blog
I am unsure on how to do these types of specific redirects. I only understand how to direct a specific URL like so Redirect 301 old.com https://new.com
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 .
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
I have just replaced my old non-Wordpress site with a Wordpress site. Now I need to redirect approximately 400 old URLs to their equivalent pages on the new site.
I have already recorded all the old urls and new urls, but when I put the code in the .htaccess file I am getting a strange result.
If I try to redirect to any url that has a number in it, the redirect tries to redirect to that url minus the numbers.
For example:
Redirect 301 /international_organizations/africaamerica_institute http://nyintl.net/international-organizations-in-new-york/2792/africa-america-institute/
Redirects to http://nyintl.net/international-organizations-in-new-york/africa-america-institute/
Which isn't actually a page and thus returns a 404 error.
Anyone have any idea what's going wrong? All my posts on the new site have the month/year syntax in the url, so this means that 95% of my redirects aren't working.
All the urls that don't contain numbers are redirecting perfectly.
I have made sure to put all my redirects ABOVE the WP rewrite rules, but that hasn't made a difference (tried them below as well).
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.