How do i stop htaccess redirecting loop - .htaccess

i am trying to redirect /article/1 to /article/1/title-of-blog
using this htaccess line
Redirect 301 /article/1 /article/1/title-of-blog
when i do that
my new link will be
https://www.mysite,com/article/1/title-of-blog/title-of-blog/title-of-blog/title-of-blog
as this loop keep going
so how to fix this problem
thanks in advance

Is /article/1 the end of the URL you want to redirect?
If so, use $ to indicate that this is where the URL ends.
ie. RewriteRule /article/1$ https://example.com/article/1/title-of-blog [R=301]

To fix this, the destination should be a full URL. This will look something like:
Redirect 301 /article/1 http://yourdomain/article/1/title-of-blog
For example, if your domain was example.com, you would have:
Redirect 301 /article/1 http://example.com/article/1/title-of-blog

Related

How to 301 redirect old website to a new one

I would like to 301 redirect my old domain say m.oldwebsite.com to m.newwebsite.com.
I believe the line below will redirect and keep the url path.
RewriteRule ^(.*)$ https://m.newwebsite.com/$1 [L,R=301]
What I need is for all links on m.oldwebsite.com to redirect to the home page of m.newwebsite.com.
Forexample:
m.oldwebsite.com/path/to
to redirect to
m.oldwebsite.com
I couldn't find a clear solution for this.
Thanks!
Remove $1 parameter from rewrite and it's done, all redirect to homepage.

301 Redirect Dynamic to new URL

i want to redirect (301) my (old) URLs/Links with mod_rewrite. But i donĀ“t know the rules i have to use in the htaccess.
My URL is one like this
https://www.pausenhof.de/referat/physik/magnetismus/14619
and now i want to move it to
https://www.pausenhof.de/referat/physik-magnetismus-14619
how is the 301 rule for redirect for google?
this here are dynmaic
https://www.pausenhof.de/referat/physik/magnetismus/14619
many thanks
i have found it. this rule work
RewriteRule ^referat/([a-zA-Z0-9.+-]+)/([a-zA-Z0-9.+-]+)/([0-9]+)$ referat/$1-$2-$3 [L,R=301]

301 redirects in .htaccess forming incorrect redirect

I'm trying to redirect http://brisbaneamazingrace.com.au/details.html to http://www.teambonding.com.au/activities/amazing-race-brisbane which is a different domain. In my .htaccess file I have
Redirect 301 http://brisbaneamazingrace.com.au/details.html http://www.teambonding.com.au/activities/amazing-race-brisbane
But the redirect goes to http://teambonding.com.au/activities/amazing-race-brisbanedetails.html
It keeps adding the details.html to the end of the redirect url. Whats up with that?
You should use RedirectMatch for regex matching:
RedirectMatxh 301 ^/details\.html$ http://www.teambonding.com.au/activities/amazing-race-brisbane
Also test this after clearing your browser cache.

301 redirect through .htaccess moving url parts

i need help setting up 301 redirect something like
the URL domain.com/f446623/welcome-new-guest/ need to be redirected to domain.com/folder/welcome-new-guest.446623/
basically f will become folder and numbers which are post IDs moved at end after the title along with dot.
You can use this rule in your DOCUMENT_ROOT/.htaccess file:
RedirectMatch 301 ^/f([0-9]+)/([^/]+)/?$ /folder/$2.$1

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]

Resources