How to redirect multiple URLs dynamically with htaccess? - .htaccess

How can I redirect each link/URL like https://example.com/blogspot/good-url to https://example.com/blog/good-url
In all links I just want to replace blogspot with blog Is this something we can achieve through .htaccess?
RedirectMatch 302 ^/blogspot/$ https://example.com/blog/$
also tried the below but doesn't seems to work:
RewriteRule ^/?blogspot/(.*)$ https://example.com/blog/$1 [R=301,L]

You can a simple Redirect for this
Redirect 302 /blogspot/ https://example.com/blog/
This will redirect all URLs from /blogspot/foobar to /blog/foobar .

Related

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 redirect in htaccess

I changed the URL of my articles so I need to be able to redirect them all, but this is how I had it set before in htaccess:
RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ index.php?tag=industry&slug=$1&id=$2
Which would give me something like:
site.com/industry/blah-blah.6842/
Now with my new site, I have the URLs set like this:
site.com/blah-blah/
So how I can do a 301 redirect in htaccess? I can't do all the articles individually because there's tons of them.
I need to be able to redirect this:
^industry/([a-zA-Z0-9-]+).([0-9]+)/$ to this: ^/([a-zA-Z0-9-]+)/$
Thanks in advance.
RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ /$1/ [R=301]

i need replace word in url using htaccess and redirect it

I need to use .htaccess file to replace a word in URL
something like this:
example URL:
http://domain.com/produts
redirect to:
http://domain.com/digital-tiles
how can i do it any idea??
That can be done in many ways as these:
Redirect 301 /products /digital-tiles
OR using RedirectMatch:
RedirectMatch 301 ^/products/?$ /digital-tiles
OR using mod_rewrite
RewriteEngine On
RewriteRule ^products/?$ /digital-tiles [L,R=301,NC]

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

How to redirect a specific page using htaccess

I've looked all over for the htaccess code to redirect a single page and haven't had any luck with many solutions.
Basically I need to redirect this:
/example/my-stuff/
to:
/example/home/
but I don't want any other pages except for /my-stuff/ to be redirected. Eg. these pages should not be redirected and kept the same.
/example/my-stuff/a-page
/example/my-stuff/anything
In the htaccess file in your document root, you can add either this:
RedirectMatch 301 ^/example/my-stuff/$ /example/home/
Or you can use mod_rewrite instead:
RewriteEngine On
RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]

Resources