So I've been looking but so far can;t find something that I'm looking for exactly. Looked at this article How can I forward ALL pages to the same exact page on a different domain using .htaccess? but it seems to only redirect my home page.
Currently, I'm using WordPress and I need to be able to forward all pages to a new domain. For example, domain1.com/about-us needs to go to domain2.com/about-us. But I have about 50 pages this needs to work on. I would like to see if there is a 1-5 line code to use for this to work.
Thanks!
Try putting this (above any wordpress rules) in the htaccess file in domain1.com's document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} domain1.com [NC]
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301]
If your 2 domains are one different webservers, or don't share a common document root, you can just use mod_alias, adding this to the htaccess file in domain1.com's document root:
Redirect 301 / http://domain2.com/
Related
I am trying to use htaccess to redirect ALL pages from a domain to a specific page on a new domain. Yes, I completely understand we will loose SEO value this way.
I currently have a cpanel redirect that makes this url:
https://www.kiss1047.net/
go to this
https://mytown-media.com/stations/kiss-104-7-kxnc-fm/
but that doesn't get any of the internal pages to redirect. I would also like all internal pages (here is an example):
https://www.kiss1047.net/listen-live
to also go to:
https://mytown-media.com/stations/kiss-104-7-kxnc-fm/
I have tried a few things, but they always carry over the page url, ie above /listen-live/
https://mytown-media.com/stations/kiss-104-7-kxnc-fm/listen-live/
and that results in a 404.
is there some htaccess magic i can employ here?
In your .htaccess file .. Make a single entry that looks like:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://mytown-media.com/stations/kiss-104-7-kxnc-fm/ [R=301,L]
This will direct ALL TRAFFIC (.*) to your other website .. Regardless of file name or directory .. And will not append the file/directory to the end of the URL .. IE listen-live
This is a 301 Permanent redirect [R=301,L] .. Which means once followed by Google, will be indexed as such .. Also will cache in users browsers so that the browser remembers the 301 instead of bouncing between websites as well.
This command in .htaccess redirects every page of your old domain to new domain's one specific URL.
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/ [R=301,L]
For your case:
RewriteEngine on
RewriteRule ^(.*)$ https://mytown-media.com/stations/kiss-104-7-kxnc-fm/ [R=301,L]
In result:
https://www.kiss1047.net/listen-live
will be redirected to:
https://mytown-media.com/stations/kiss-104-7-kxnc-fm/
This should be simple and I'm not sure why I can't find anything on it...
Simply put
http://www.abcd.org/efg/ (this is a single article in a Joomla site, the rest of the domain needs to stay active, so just the efg part is what I need redirected.)
needs to redirect to
https://www.xyx.com/lmn-op-qrs/
Is this possible in a Joomla site (Joomla Redirect component fails)?
I see plenty for redirecting within a certain domain, and even redirecting the entire domain to a new domain, but nothing about redirecting part of a domain to a new URL.
I'm sure I could pop in a PHP page to the /abcd.org/efg/ directory and redirect it that way, but wondering if it was possible using the .htaccess file.
Thanks!
You may try this rule as your topmost rule:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+efg[?\s/] [NC]
RewriteRule ^ https://www.xyx.com/lmn-op-qrs/ [L,R=301]
put this rule in top of .htaccess (on http://www.abcd.org/ root directory)
RewriteEngine On
RewriteRule ^efg/$ https://www.xyx.com/lmn-op-qrs/ [R=301,L]
I've dug around without much luck finding a solution.
I have a WordPress MultiSite using sub-directories as "temp" URLs so clients can review prior to mapping their domain name.
The login for the mapped domains is domain.com/ui which works with a redirect in my htaccess.
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ui$ /wp-login.php? [R=301,NE,NC,L]
I've also tried this RewriteRule ^ui(.*)$ /wp-login.php [L,R=301]
However, when attempting to login to a temp URL as described above it does not redirect.
I would like a solution that disregards sub-directories and for that matter any permalink structure and redirects /ui to /wp-login.php
Here are a few examples.
http://adopttheweb.com/ui
http://iemajen.com/emajenwebservices/ui
These are both on the same MultiSite blog. The first has been mapped to a domain whereas the second has not and is simply running at a "sub-directory" of the root / parent site.
Put the following code at main directory .htaccess file
RewriteEngine On
RewriteRule ^ui(.*)$ /wp-login.php [L,R=301]
You can also do it by PHP by putting header('Location: path/to/target.php'); at the ui directory index page etc
Yes, I searched the site and found many examples, but my .htacces skills are very limited, so NONE of examples worked for me after trying to modify them to suit my needs.
Put simply, if URL is like "index.php?/............" user should be redirect to example.com (ideally, to example.com instead of example.com/index.php) immediately.
I need this because I have an old domain that was used for forum, so I get thousands of requests like "example.com/index.php?/whatever" and all these virtual pages display the same content, which hurts my rankings badly.
My index.php file has NO parameters at all (but some other files have, so the rule shouldn't affect other files).
Thanks a lot!
Try adding these rules to the htaccess file in your document root (preferably before any other rules you have there)
RewriteEngine On
RewriteCond %{QUERY_STRING} ^/
RewriteRule ^index\.php$ /? [L,R=301]
How can I do a 301 redirect of ALL pages on a site to the same exact page on a different domain using .htaccess?
For example, forward:
www.currentdomain.com/page1.php
www.currentdomain.com/page2.php?p=1&t=75
www.currentdomain.com/archived/old/page100.php
To:
www.newdomain.com/page1.php
www.newdomain.com/page2.php?p=1&t=75
www.newdomain.com/archived/old/page100.php
According to about.com's article, the following should redirect ALL traffic to a new domain:
RewriteEngine ON
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
In the root of your website add in the .htaccess file:
Redirect 301 /page1.php www.newdomain.com/page1.php
Without mod_rewrite you can't transfer the parameters. Further you have to have 1 line per existing file with .htaccess that you want to forward.
I know you didn't ask, but you can do the entire domain including the parameters with 1 line using mod_rewrite.