301 redirect on pagination with parameters - .htaccess

I am trying to setup a 301 redirect with parameters such as:
http://www.domain.com/?p=2 should redirect to http://www.domain.com/page/2/
http://www.domain.com/tag/tagname/?p=2 should redirect to http://www.domain.com/tag/tagname/page/2/
Obviously the redirect should work with all the page numbers (1,2,3,4,etc) and with all the tag names.
Does anyone have a solution?

Related

301 redirects specific pages with get parameters and non-specified pages

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

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.

301 redirect entire website to a single page

I have a website that I would like to implement a 301 redirect for an entire site (every page on the website) to a single page. Basically I have an old blog and I want to 301 redirect every page on that blog to our Facebook page instead.
When I search google I get the response to do it this way:
Redirect 301 / https://www.facebook.com/whatever
This works, however the problem I am running into is if someone types in a subfolder of the website such as: www.oldwebsite.com/subfolder it will redirect to https://www.facebook.com/whateversubfolder which is not what I need.
I need every possible page on oldwebsite.com to redirect to the single page https://www.facebook.com/whatever. Thanks!
You want to use RedirectMatch:
RedirectMatch 301 ^(.*)$ https://www.facebook.com/whatever

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.

301 redirects and htaccess issue

I'm fairly new to htaccess, so if this is a noob question I apologize.
Recent I launched a newly designed website, and created 301 redirects for all of the old pages.
An example of one of the redirects is:
redirect 301 /about-busch-systems.html http://www.buschsystems.com/About/The-Busch-Company.php
The url:
"redirect 301 /about-busch-systems.html http://www.buschsystems.com/About/The-Busch-Company.php"
is in actuality:
"http://www.buschsystems.com/index.php?p=About&subPage=The-Busch-Company"
The redirect is sending me to the right page, with the proper URL, except the old page is being strung on the end as a variable.
Example:
redirect 301 /about-busch-systems.html http://www.buschsystems.com/About/The-Busch-Company.php
Sends me to "http://www.buschsystems.com/About/The-Busch-Company.php?p=about-busch-systems
Any ideas of why this is happening?
Thanks in advance!
Because that is what Redirect is supposed to do:
Then any request beginning with URL-Path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-Path will be appended to the target URL.
Use RedirectMatch if you want more control.

Resources