301 redirect from htaccess - .htaccess

I'm trying to create permanent redirects for outdated URL's on my site.
For example I have: www.mydomain.com/?v=tv and want it have a permanent 301 redirect to www.mydomain.com/tv.php
I tried this code in my htaccess file but it did not work:
Redirect /?v=tv http://mydomain.com/tv.php
Any Help?

RewriteRule ^tv.php$ http://guessthelogo.com/?v=tv [R=301,L]

I think your missing "301" after "Redirect":
Redirect 301 /?v=tv http://guessthelogo.com/tv.php

Related

htaccess redirect 301 does not work

There was an old site, and all your URLs have changed.
One URL that was well found on Google was:
mydomain.com/datacenters
Now I want to redirect this URL to:
mydomain.com/data-centers
In htaccess I did:
redirect 301 /datacenters /data-centers
But it does not work, what am I doing wrong?
Only work with:
RewriteRule ^datacenters http://mydomain.bla/data-centers [L,R=301,NC]

Redirect 301 of subdirectory

There was a link example.com/shop/product-1
now link is example.com/newshop/product-1
I try to wtite htaccess rule to redirect from /shop/ to /newshop/
RewriteRule ^(.*)shop(.*)$ $1newshop$2 [QSA,L,R=301,NC]
Doesn't work. Where is mistake?
You can use the following redirect
Redirect 301 /shop/ /newshop/
This will redirect /shop/.* to /newshop/.*

htaccess 301 redirect not working for new subdomain site

I'm moving my site so wanted to test a page and redirect in the htaccess file:
I wanted to redirect
http://www.martinspencephotography.co.uk/blog/yes/mini-photo-series-minimalism-gallows-hill-outside-cloughmills
to
http://landscape.martinspencephotography.co.uk/minimalism-at-gallows-hill/
using the following in the .htaccess file:
Redirect 301 /blog/yes/mini-photo-series-minimalism-gallows-hill-outside-cloughmill http://landscape.martinspencephotography.co.uk/minimalism-at-gallows-hill
It didn't works there any reason why this might not work?
Try
RewriteRule your_page.html
http://your.url.fr/yournewpage.html [R=301]
And what about
http://www.martinspencephotography.co.uk/blog/yes/mini-photo-series-minimalism-gallows-hill-outside-cloughmills http://landscape.martinspencephotography.co.uk/minimalism-at-gallows-hill/ [R=301]
So the answer was to use DRUPAL NODE...

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]

htaccess redirection, urls with hashes

I have urls like these:
http://domain.com/test/MzA5
http://domain.com/test/AtbC
http://domain.com/test/4gCA
How to make htaccess rule which will redirect all urls like http://domain.com/test/[hash here] to one page, for example http://domain.com/page.html
Try:
Redirect 301 /test/MzA5 /page.html
If you have a lot of those hashes, you can make a lot of 301 redirects:
Redirect 301 /test/MzA5 /page.html
Redirect 301 /test/AtbC /page.html
Redirect 301 /test/4gCA /page.html
or consider using a RewriteMap (which requires access to the server config, won't work in .htaccess file)
To redirect all URLs of the form /test/*/ to page.html, use the following rewrite:
RewriteEngine On
RewriteRule ^/test/[^/]+/? /page.html [R=301, L]

Resources