My domain http://bretthowardsproul.com is active but the www version, www.bretthowardsproul.com , shows a blank screen.
I added this .htaccess but it doesn't change the results:
# Redirect www to no-www - via bit.ly/www-no-www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^bretthowardsproul.com$ [NC]
RewriteRule ^(.*)$ http://bretthowardsproul.com/$1 [L,R=301]
I then tried test.bretthowardsproul.com and got a 404. So is it something in my .htaccess?
If not, do I need to do something with a CNAME? Is there something I can check in Firebug to see what's going on at www ?
Make sure the "www" CNAME exists for your domain, and is pointing to your # record, otherwise "www" traffic won't go to the same place that your domain goes to without "www".
A quick google search should help you figure out how to add the CNAME to your registrar. For GoDaddy, this is helpful: http://www.google.com/support/a/bin/answer.py?answer=47610
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/
Assume I have two domain names example1.com and example2.com. I forwarded example1.com to example2.com using the domain forwarding on hosting panel. It works fine but when I go to example1.com/sub it just shows example2.com as the URL. I want it to show example2.com/sub. I tried URL rewriting but no luck so far. It just keep loading and shows nothing. Am I missing something ?
This the rule I used.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example1.com$ [NC]
RewriteRule (.*) http://www.example2.com/$1 [R=301]
First make sure that you've cleared your browser's cache. If it's a 301 redirect your browser will cache the redirect. Then make sure to turn off your hosting panel's forwarding.
Other than that, your rule should work fine, assuming it's at the top of the htaccess file in example1.com's document root.
In RewriteCond rule you use !, which mean negate the result of the condition.
Right now *.foo.com and *.bar.com are aliased to the same vhost with LAMP. Right now it, of course, shows the same content with every URL. But I don't actually want this to be what happens, and I want the other domains to actually redirect to foo.com. I'm assuming this is possible with the .htaccess file.
EDIT: I'm hosting this on my own server, so I'd also like the IP address to redirect to foo.com
Use a rewrite condition in your .htaccess to selected everything not for foo.com and redirect it then:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^foo\.com$
RewriteRule ^(.*)$ http://foo.com/$1 [R=301,L]
I want to create a subdomain that points to an outside IP address on my virtual hosted site. I created an A record in my DNS settings with the name of the subdomain I'd like, then I selected "A" record, and added the IP address of the site I'd like to redirect to.
When I go to the subdomain, it loads my main site as if it exists and the URL stays as the subdomain.site.com.
I then tried other subdomains that don't exist in my DNS settings to see if they would load, and they do.
doesntexist.site.com
...loads my site too. Can you help me understand what's going on?
Fixed by adding some rules in .htaccess:
# Redirect any non-existing subdomains
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^site\.com$ [NC]
RewriteCond %{HTTP_HOST} !^excludedsubdomain\.site\.com$ [NC]
RewriteRule ^(.*)$ http://ite.com/$1 [L,R=301]
</IfModule>
Though, still not sure why my excluded subdomain doesn't redirect to the new IP address I assigned.
I have shared hosting on webfaction and I want to have www.mydomain.com forward to mydomain.com, in the same way that www.stackoverflow.com redirects to stackoverflow.com. In the webfaction control panel I set up a CNAME record linking the www.mydomain.com subdomain to mydomain.com, but this doesn't seem to be working. Maybe what's messing it up is that mydomain.com is a virtual host and doesn't have an A record to an IP address?
Anyway, can someone help me figure out the right way to do this, either in the webfaction control panel or directly in the httpd.conf file? Thanks in advance.
The solution I use is to create a Static/CGI/PHP application (which I call redirect), and place an .htaccess file at its root. I point all the domains and subdomains that need redirecting to this application, and I then populate the .htaccess file with all the necessary redirection directives for my server, like so:
RewriteEngine on
RewriteCond %{HTTP_HOST} www.example.com
RewriteRule ^(.*) http://example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} www.example1.com
RewriteRule ^(.*) http://example1.com/$1 [R=301,L]
It works well, and because it is instantaneous, it's easy to debug.