I have a domain that needs to be redirected in order to use a shared SSL certificate. I can redirect the domain no problem, the issue I have is the way this leaves the URL formatting i.e.:
http://www.example.com is redirecting to https://myhost.secure.com/www.example.com
I'm looking to hide the "myhost.secure.com/" part using htaccess but can't find a valid way to do it (I'm a complete novice, sorry). Redirect is being done via htaccess using code below:
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:https} !=on
RewriteRule ^(.*) https://myhost.secure.com/www.example.com/$1 [R,L]
How can I modify this to only display my domain and not the full redirected URL? The redirect works correctly, I see the site as it sits in the secure area of my FTP, but I don't want visitors to see the hosts redirect in the URL.
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'm new at programming. We have an office project, the website's URL is www.project.com.ph (sample name), this is already a live website from the client. But the released printouts have the instructions for the users to go to www.project.com/ph which is wrong and we can't reprint the material since it already reached plenty of event places.
Now the problem is, we need to redirect to www.project.com.ph automatically if the users type in the browser's address bar www.project.com/ph. I ask if this is possible without any kind of CMS or Wordpress and how to actually do it? We bought a new domain www.project.com for this. Any kind of help is appreciated.
Try the following near the top of your .htaccess file in the root of www.project.com. This works OK (although marginally less efficient) if both domains are pointing to the same place, since it specifically checks that we are requesting the "wrong" domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?project\.com$ [NC]
RewriteRule ^ph/?(.*) http://www.project.com.ph/$1 [NC,R=302,L]
This will redirect requests for www.project.com/ph (no slash), www.project.com/ph/ (with a trailing slash) and www.project.com/ph/<whatever> to http://www.project.com.ph/<whatever>.
This is a temporary (302) redirect. Change it to a permanent (301) only when you are sure it's working OK.
From kj.'s answer on a similar question, here
In your .htaccess for www.project.com, this should do the trick.
RewriteEngine on
RewriteRule ^(.*)$ http://www.project.com.ph/ [R=permanent,NC,L]
This will redirect any request to project.com to the domain http://www.project.com.ph/
To include the path after the /ph/` you can use this.
RewriteEngine on
# redirect including path after ph/ (e.g. project.com/ph/directory/file.php to project.com.ph/directory/file.php
RewriteRule ^ph/(.*)$ http://www.project.com.ph/$1 [R=permanent,NC,L]
# redirect any other requests to project.com.ph index
RewriteRule ^(.*)$ http://www.project.com.ph/ [R=permanent,NC,L]
You can redirect (301 redirect) the URL using RewritrRule in .htaccess file
RewriteRule "http://www.project.com/ph/(.*)" "http://www.project.com.ph/$1" [L,NC,R=301]
A client of mine wants to change their domain name, but wants to keep their Google ranking. To do this, they've pointed two domain names to the same IP, but we're having an issue where if you visit the site via the old domain, you get a security certificate warning and the page just loads with the old domain name.
What I'd like to do is detect when someone's coming to the site via the old domain and rewrite it to the new domain. For example, if they where to visit example.com/some-page.htm, it would rewrite to https://www.dummy.com/some-page.htm.
I found this code snippet somewhere that purports to do this, but it just brings the site down:
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ https://www.dummy.com/$1 [R=301,L]
This is a WordPress site, so I'm using the normal WordPress rewrite rules, and I'm using the HTML5 Boiler Plate .htacess to enable http > https redriects, non-www > www redirects, and force HTTP Strict Transport Security, if any of that makes a difference.
You need to change condition to:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^ https://www.dummy.com%{REQUEST_URI} [NE,R=301,L]
However keep in mind if you visit https://exampl.com and certificate is for dummy.com then SSL cert warning will still be there because SSL handshakes before mod_rewrite is invoked for redirecting to new site.
I just rebuilt a site that is currently located at
http://domainnamehere.com/v2
The existing site is located at
http://domainnamehere.com/
I need to set up a redirect so that when someone goes to the old site, it redirects to the new site. I did this on the htaccess file:
Redirect /index.html http://domainnamehere.com/v2/
But this only redirects the homepage, not the rest of the site. I also have another directory that is linked to a separate domain. The above htaccess code redirects http://anotherdomain.com to http://domainnamehere.com/v2. I do not want it to redirect other domain names. THe reason it is redirecting the other domain name is because the files are located in a directory on domainnamehere.com. I hope that makes sense!
If someone goes to http://domainnamehere.com/somethinghere I also want it to redirect to the 404 error page that would be located at http://domainnamehere.com/v2/somethinghere
Basically, I need proper htaccess code for this situation!
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainnamehere\.com [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/v2/$1 [R=301,L]
Note: jfrobishow technically answered this first, this is just a fix.
Edit: Added optional www.
This should forward {whatever is after you slash} to /v2/{whatever is after you slash}
RewriteCond %{HTTP:Host} ^domainnamehere\.com$
RewriteRule /(.*) domainnamehere\.com/v2/$1
EDIT: this is for isapi rewrite, but the syntax is similar if you are using mod_rewrite.