I want to move a Folder and all subfolders to another root.
Example:
http://www.example.de/de/product1
to:
http://www.example.de/product1
I want to realize this via .htaccess .. I only wanna move "/de/" and everything that follows after "/de/" to the Root via 301 Redirect.
So if a User/Bot request http://www.example.de/de/product3 there will be a Redirect to http://www.example.de/product3
Also if a User/Bot request http://www.example.de/de/product3/details there will be a Redirect to http://www.example.de/product3/details
You can use Redirect directive to rediret everything inside /de folder to root.
Redirect /de/ /
This will redirect /de/foobar to /foobar using 302 Default redirect status .
You can also set a 301 argument in Redirect ,this makes the redirect permanent
Redirect 301 /de/ /
Related
I am trying to setup a redirection with .htaccess file.
So far I have this:
Redirect 301 /temat-konfiguracja-internetu-w-a2mobile https://infomobile.pl/konfiguracja-internetu-w-a2mobile-22500
Redirect 301 /temat-konfiguracja-mms-w-a2mobile https://infomobile.pl/konfiguracja-mms-w-a2mobile-22499
Redirect 301 /temat-jak-sprawdzic-stan-konta-w-a2mobile-oraz-inne-kody-ussd-w-a2mobile https://infomobile.pl/jak-sprawdzic-stan-konta-w-a2mobile-oraz-inne-kody-ussd-w-a2mobile-1812
Redirect 301 /temat-jak-sprawdzic-swoj-numer-telefonu-w-a2mobile https://infomobile.pl/jak-sprawdzic-swoj-numer-telefonu-w-a2mobile-22497
Redirect 301 /temat-konfiguracja-apn-internetu-i-mms-samsung-galaxy-s4 https://infomobile.pl/konfiguracja-apn-internetu-i-mms-samsung-galaxy-s4-11561
Redirect 301 /forum-internet-mobilny-w-a2mobile https://infomobile.pl/internet-mobilny-w-a2mobile-31
Redirect 301 /temat-ostrzegam-roaming-nie-dziala-w-a2mobile https://infomobile.pl/ostrzegam-roaming-nie-dziala-w-a2mobile-22494
Redirect 301 /temat-stan-konta-a2mobile https://infomobile.pl/stan-konta-a2mobile-22498
Redirect 301 /temat-rozwiązany-problem-z-konfiguracja-apn-na-urzadzeniu-meizu-m2-mini https://infomobile.pl/rozwiazany-problem-z-konfiguracja-apn-na-urzadzeniu-meizu-m2-mini-1817
Redirect 301 /temat-logowanie https://infomobile.pl/logowanie-761
Redirect 301 /mapa-index.xml https://infomobile.pl/sitemap/sitemap.xml
But... for all the other pages I want to setup a whole domain redirection (so for all the pages that are not on the list I want to point aero2forum.pl to infomobile.pl). Is there any way to accomplish this?
To redirect everything else to the root of the target domain you will need to add a (mod_alias) RedirectMatch directive after your existing (mod_alias) Redirect directives.
For example:
:
# Redirect everything else to the target domain's homepage
RedirectMatch 301 ^ https://example.target/
However, it should be noted, that from a search engine perspective, multiple redirects to the homepage will likely be seen as a soft-404. (And reported as such in Google Search Console.)
This does assume that the source and target domains point to different server's. Otherwise, this will naturally result in a redirect loop. You could avoid the redirect-loop by not redirecting the homepage, eg. ^/.. However, if both domains point to the same server then you will need to convert everything to use mod_rewrite instead and explicitly check the requested hostname.
Aside: You cannot use a (mod_rewrite) RewriteRule here since it will take priority over the existing Redirect directives (regardless of the order) and end up redirecting everything to the homepage of the target domain.
I need to create a 301 redirection from myOldSite.com to myNewSite.com
I have this code in the htaccess in myOldSite.com
#Redirect 301 / https://myNewSite.com/myPage/
This works fine to redirect myOldSite.com but it does not work to fire the right redirection for myOldSite.com/services.html:
myOldSite.com is properly redirected to myNewSite.com/myPage
But
myOldSite.com/services is redirected to myNewSite.com/myPage/services.html This is wrong.
As you can see servicesis appended to the end. This is not what I need. I need:
myOldSite.com/services to be redirected to myNewSite.com/myPage
Any url which start with myOldSite.com/ANYTHING_HERE should be redirected to myNewSite.com/myPage
Use RedirectMatch
RedirectMatch 301 / https://myNewSite.com/myPage
This will not append the old URL subpath to the destination URL.
I have two URLs: old-site.com and new-site.com.
My root folder on the old-site.com has NO FILES in it but only the .htaccess file. I don’t want to use the old domain anymore. However, I do want to pass the link juice to the new domain. Therefore, I created 301 Redirects in the .htaccess file and put it in the root folder on the old-site.com.
Why would the Redirect 301 append the “old-site.com/…” to the new-site.com?
My entire .htaccess looks like this (I skipped a few links to shorten it):
#Begin 301 Redirects
Redirect 301 / https://www.new-site.com/
Redirect 301 /contactus https://www.new-site/contact-us/
Redirect 301 /rentals https://www.new-site/lodging/
Redirect 301 /lift.html https://www.new-site/our-rentals/boat/
Redirect 301 /rentals.html https://www.new-site/our-rentals/
Redirect 301 /map.html https://www.new-site/contact-us/
Redirect 301 /giftshop https://www.new-site/store/gift-shop/
#End 301 Redirects
I don’t have any Rewrites. The above is my entire code.
The following redirect works fine:
Redirect 301 / https://www.new-site.com/
However, any other redirect creates the following absolute path on the new-site.com with a 404 error:
If I redirect:
Redirect 301 /contactus https://www.new-site/contact-us/
It goes to:
https://www.new-site.com/old-site.com/contactus
or
If I redirect:
Redirect 301 /lift.html https://www.new-site/lift/
It goes to:
https://www.new-site.com/old-site.com/lift.html
Why would the Redirect 301 append the “old-site.com/…” to the new-site.com?
Thank you,
Derek
Your rules will not do what you need correct because of this line Redirect 301 / https://www.new-site.com/ which will match any request first and if you put it in the last it will also match any request so , if you want it to match only root use RedirectMatch to be able to use regex like this :
RedirectMatch 301 /?$ https://www.new-site.com/
By this the rest of rules will work as expected .
Note: clear browser cache the test
The URL I'm working with is something like this...
old-website/directory/sub-directory/last-directory
I need to capture just the sub-directory portion and then use that in a URL for a redirect. For example, redirect to new-website/working/sub-directory/page
However, I also need a redirect that works for old-website/directory/sub-directory to redirect to the same new-website/working/sub-directory/page
You can use this RedirectMatch rule in your root .htaccess:
RedirectMatch 302 ^/directory/([^/]+)(?:/.*)?$ http://working/$1/page
Change 302 to 301 once you verify that rule is working fine.
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/