.htaccess 301 redirect to site B with referrer from site A - .htaccess

I am trying to make the following redirection with .htaccess
Redirect 301 pageA.php to https://newSite/pageB.php?referrer=pageA.php
I need the pageA.php to be redirected to another site along with a referrer from the origin site containing pageA.php
Is there a way to do this in htaccess?

Try below code
RewriteRule ^/pageA.php https://newSite/pageB.php?referrer=pageA.php [R=301,L]

Related

Redirect URL to a Subdomain by .htaccess

I am trying to redirect a URL to a subdomain
I am already redirecting form a old domain to a new domain
Like http://abc.com to http://xyz.com by the below code
RewriteEngine on
Redirect 301 / http://xyz.com/
So my Url becomes http://xyz.com/blog/
Now I want to redirect http://abc.com/blog/ to http://blog.xyz.com
How can I do this
You don't need to turn the rewrite engine on, as the Redirect directive is part of mod_alias. You can add the other redirect before the one that redirects to xyz.com:
Redirect 301 /blog/ http://blog.xyz.com/
Redirect 301 / http://xyz.com/

Redirect www.domain.com/112 to www.domain.com/ using htaccess 301 redirect

I have thousands of URLs on my website like:
www.domain.com/112
and
www.domain.com/113
I'd like to redirect these straight to www.domain.com.
Can someone explain how I do this using the 301 Redirect with htaccess?
Thank you
RewriteEngine on
RewriteRule ^(\d+)/?$ / [R=301,L]
This will redirect any digit-based request in document root to index page

301 redirect isn't working

I have a blog that I'm trying to redirect to a different domain.
Old domain: http://harrisonfjord.com
New domain: http://agoodman.com/blog/
Google states that you should do 301 redirection for all pages, so I took a list of urls from my XML sitemap and just manually set up the redirection.
Here's what I've put in my .htaccess file: http://pastebin.com/PkKNbJKf
The file structure is the same across both domains, so I can simply redirect each page as follows:
redirect 301 http://harrisonfjord.com/ http://agoodman.com.au
redirect 301 http://harrisonfjord.com/whatever http://agoodman.com.au/blog/whatever
However, this currently isn't working. Do I need to put the redirection in an tag or something?
What if you redirect your old-domain to new new domain completely?
# redirect an entire site via 301
redirect 301 / http://agoodman.com/blog/
Also try using RewriteEngine as:
RewriteEngine On
RewriteRule ^(.*)$ http://agoodman.com/blog/$1 [R=301,L]

How to do 301 redirects with folders & subfolders?

I need to redirect all the old URLs on my site to new URLs, but am having issues. A given URL and its subfolders need redirecting to the same page.
For example, this is the first one:
redirect 301 /panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html
This works ok. However there are these size sub-pages which need to redirect to the same location:
redirect 301 /panache/sports-bra/30DD http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30E http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30F http://www.newdomain.co.uk/sports-bra.html
And these don't work, I end up at a location like the following:
http://www.newdomain.co.uk/sports-bra.html30DD
See the way the last part of the path is appended to the url? I'm guessing it's because the second redirect is conflicting with the initial 301 redirect?
I have also tried using this rewrite rule but have had no luck. The site is Magento so I don't know if this has some effect? mod_rewrite is enabled on the server.
RewriteRule ^panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html [R=301]
Any help mucha ppreciated.
Try this.
RewriteEngine on
RewriteRule ^(panache/sports-bra/.*)$ /sports-bra.html [L,R=301,NC]

Redirect all but some to new URL?

I am moving site and I want to do a 301 redirect on all but some of the URLs,
Like this:
oldsite.com/* -> www.newsite.com
oldsite.com/specific/article/to/redirect -> www.newsite.com/fancy/blah
So there are a few things I want to redirect to specific pages but all the rest should just goto root, how can this be done in .htaccess?
Add the following to the .htaccess file in the root directory of your old site.
#place your specific redirects first
Redirect 301 /specific/article/to/redirect http://www.newsite.com/fancy/blah
RewriteEngine on
#then your general redirect all to new site last
RewriteRule ^ http://www.newsite.com%{REQUEST_URI} [L,R=301]
There's RedirectMatch if you've got only one URL that needs to be exempted.
RedirectMatch permanent !/specific/article/to/redirect http://www.newsite.com
for multiple URLs, you'd probably be better off with mod_rewrite and an external rewritemap that lists the urls to be exempted.

Resources