I switch my Business from one Domainname to another and want to use a 301 Redirect/Rewrite to keep the Google Ranking.
The special case is, that the Startpage and One other Page should go to a new Subpage on the new Domain, everything else should stay the same because of the structure of the new Domain is the same like the old one.
I tried several kinds of RegExp and another order. Maybe I misunderstand the path to a solution completly.
Maybe I should do a simple 301 Redirect on the Old Webpage and try to look into the referer on the New Apache Configuration and make an internal rewrite to /catvilla/
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.old.co.nz$ [NC]
RewriteRule ^(.*)$ https://www.new.co.nz/oldname/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.old.co.nz/$ [NC]
RewriteRule ^(.*)$ https://www.new.co.nz/oldname/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.old.co.nz/pricelist/$ [NC]
RewriteRule ^(.*)$ https://www.new.co.nz/oldpricelist/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.old.co.nz/ [NC]
RewriteRule ^(.*)$ https://www.new.co.nz/$1 [L,R=301]
The Apache Config in my VirtualHost right now, redirect everyging to www.new.co.nz/oldname all the time, eben for example for http://www.old.co.nz/webcam, what should go to www.new.co.nz/webcam.
Frank
So far I see the following is working:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteRule ^(.*)$ https://www.new.co.nz/oldname/ [L,R=301]
RewriteCond %{REQUEST_URI} ^/pricelist/$ [NC]
RewriteRule ^(.*)$ https://www.new.co.nz/oldpricelist/ [L,R=301]
RewriteRule ^(.*)$ https://www.new.co.nz/$1 [L,R=301]
Related
I'm trying to redirect user request to my domain in .htaccess file.
My requirement is for example if user request for example.co/abc it should redirect to www.example.co/abc.
Below is my rewrite rule.
RewriteCond %{HTTP_HOST} ^example.co/Abc [NC]
RewriteRule ^(/Abc)$ https://www.example.co/$1 [L,R=301]
After adding the above two lines in my .htaccess file it is redirecting from example.co to www.example.co
I tried in different ways still not getting where i'm doing mistake.
Any help would be appreciated.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.co [NC]
RewriteRule ^(.*)$ http://www.example.co/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{www.example.co} [L,R=301]
RewriteCond %{HTTP_HOST} ^example.co [NC]
#RewriteRule ^(/*)$ https://www.example.co/$1 [L,R=301]
RewriteRule ^/?(Abc)/?$ https://www.example.co/$1 [L,R=301]
I am stuck in redirecting my urls. I think i am almost there but can't oversee what i am missing. When i test the redirect is goes to the correct url, but sticks the old url behinde the new url.
This is where i got stuck:
RewriteCond %{QUERY_STRING} lang=uk&page=page
RewriteRule ^(.*)$ domain/page/ [L,R=301]
RewriteCond %{QUERY_STRING} lang=fr&page=page
RewriteRule ^(.*)$ domain/page/ [L,R=301]
RewriteCond %{QUERY_STRING} lang=uk&page=about
RewriteRule ^(.*)$ domain/about/ [L,R=301]
RewriteCond %{QUERY_STRING} lang=uk&page=about
RewriteRule ^(.*)$ domain/about/ [L,R=301]
RewriteCond %{QUERY_STRING} lang=uk&page=news
RewriteRule ^(.*)$ domain/info/ [L,R=301]
RewriteCond %{QUERY_STRING} lang=fr&page=news
RewriteRule ^(.*)$ domain/info/ [L,R=301]
I am also scared i get stuck with a big htaccess file if i do all redirects individual. Would that slow things down?
Lang=nl, uk, us, fr all go to the same page.
not all page= got the same pagename after the change.
Thanks in advance,
You can have specific redirects first where page name is not same as target followed by a single rule where query parameter page has same value as the target URI. So your code can be shortened to these 2 rules only.
RewriteEngine On
RewriteCond %{QUERY_STRING} lang=(fr|uk|us|nl)&page=news
RewriteRule ^ /info/? [L,R=301]
RewriteCond %{QUERY_STRING} lang=(fr|uk|us|nl)&page=([^&]+)
RewriteRule ^ /%2/? [L,R=301]
I have the following problem. I have a site where some pages must be redirected to the https-secured equivalent of the link.
I tried several things but in the end it seems that the server ends up in a loop redirecting :(
Now I redirect every page to the https page but that is not what I want to.
This is the code I use right now:
RewriteCond %{http_host} ^www.domain.nl
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.domain.nl/$1 [L,R=301]
I would like to have al urls starting with bo- have https.
examples:
http://www.domain.nl/bo-users -> redirects to https://www.domain.nl/bo-users
http://www.domain.nl/bo-groups -> redirects to https://www.domain.nl/bo-groups
but
http://www.domain.nl/about-us -> stays at http://www.domain.nl/about-us
It is clear to me I need some wildcards in the rewrite condition for all urls startin with bo-.
We are using apache on the server.
Hope someone can send me in the right direction.
Thanks,
Frank
Update after the tips from Anubhava.
I current;y have this htaccess but I can't get it working (even when clearing the cache in my browser)
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain\.nl$ [NC]
RewriteCond %{HTTPS} on
RewriteRule !^bo- http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC,NE]
RewriteCond %{HTTP_HOST} ^www.domain\.nl$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^bo- https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC,NE]
#rewrites een url to www.
RewriteCond %{HTTP_HOST} ^[a-z0-9-]+\.[a-z]{2,6}$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$0 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Hope for some extra help!
Thanks,
Frank
I just opened another call. The initial answer worked fine!
Use this rule:
# force HTTPS for bo- URIs
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.nl$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^bo- https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC,NE]
# force HTTP for non bo- URIs
RewriteCond %{HTTP_HOST} ^www.domain\.nl$ [NC]
RewriteCond %{HTTPS} on
RewriteRule !^bo- http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC,NE]
I'm trying to configure a redirect for the domain kb3mmy.net. I'd like it to work that if somebody goes to kb3mmy.net/blog it redirects them to christiaanconover.com/category/kb3mmy/. This is the only redirect I want to take place like this, so I can hard code the subdirectories.
Also, there's an existing redirect rule set up on kb3mmy.net that sends any traffic to the root of that domain to a sub page on christiaanconover.com, but any sub page traffic to kb3mmy.net to the corresponding sub page on christiaanconover.com, so that rule cannot be affected by the new one. Here's the code for the existing rule:
RewriteRule ^$ http://christiaanconover.com/kb3mmy/ [L,R=301]
RewriteRule ^(.*)$ http://christiaanconover.com/$1 [R=301]
Any help is appreciated.
RewriteRule ^blog/?(.*)$ http://christiaanconover.com/category/kb3mmy/ [R=301,L]
RewriteRule ^$ http://christiaanconover.com/kb3mmy/ [L,R=301]
RewriteRule ^(.*)$ http://christiaanconover.com/$1 [R=301,L]
How about:
RewriteCond %{HTTP_HOST} kb3mmy.net
RewriteRule ^blog/?(.*)$ http://christiaanconover.com/category/kb3mmy/ [R=301,L]
RewriteCond %{HTTP_HOST} kb3mmy.net
RewriteRule ^$ http://christiaanconover.com/kb3mmy/ [L,R=301]
RewriteCond %{HTTP_HOST} kb3mmy.net
RewriteRule ^(.*)$ http://christiaanconover.com/$1 [L,R=301]
I have a client folder located at http://www.example.com/client
However, I've now installed SSL on the server, and want to add a permanent redirect using HTACCESS so that whenever /client is accessed, that it redirects to: https://www.example.com/client
Anybody know how to do that?
I've redirected my domains in the past like this:
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
This should not affect the solution, but the site must still redirect to www.example.com FIRST, and then to https://www.example.com/client if for example, http://www.example.co.za/client is entered.
Try this:
RewriteCond %{HTTPS} !on
RewriteRule ^client(/.*)?$ https://www.example.com%{REQUEST_URI} [L,R=301]
RewriteEngine On
RewriteRule ^/?$ https://www.example.com/client [301,NC,L]
It tells the apache, whenever the url is https://www.example.com or either with slash at the end, will redirect to ur /client