I have a domain e.g. named www.example.com, when people type in example.com, it still can be accessed, but won't automatically add that 'www' to the url.
But as for website like facebook, if you type in facebook.com, it'll automatically add that 'www', BEFORE loading the page for you.
Probably I didn't explain it well, but guess you see the difference and get my point anyway.
So how can I make my domain acts like facebook, when people type example.com, it'll automatically add that www for them?
EDIT:
Ok, so I need a redirect to the 'www' subdomain. Actually I'm using nodejs, which hosted on Amazon EC2, to serve the webpage instead of Apache HTTP. So any equivalent of .htaccess in nodejs area?
I guess now the question shifts to more nodejs oriented, and it turns out it becomes a redundant of this thread:
Redirect all requests using Express 3?
Thanks all for your help.
you have to set your domain 301 permanent redirect in your control panel.
if your website is hosted in CPANEL then
GOTO -> Redirects in ( Domains Menu )
Choose the type Permanent (301)
choose your domain.com
www.domain.com in redirects to→ __
check the box on Redirect with or without www
finally CLick ADD
if your website is hosted in PLESK then
do it in your program level
or
plesk11.0.29 version above supports the 301 peramanent
You can do all of this with a .htaccess file.
https://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/
Add this in a file named .htaccess on your host, but set it to the URL you want your main page to be.
To make a .htaccess file, you can always go in FTP, upload an empty .txt file, open it with notepad, put in the lines of code above, then rename it to .htaccess.
Related
I have a DNS linked to Sites using CNAME from www in my DNS settings below. So when i type www.website.com it redirects me properly but when I type website.com nothing happens. I am thinking about editing # to add something to redirect to the www but I am not sure how to do that. Cold you please help me out?
Depends on the web server your utilizing, but what your looking for is url redirects. You can put in different urls and have the redirect to the primary. So you would place your domain.com in here to redirect to your binded url which is the www.domain.com. should also be able to use it to redirect http to https, though this is usually less of an issue with browsers and servers today.
Is there a way, using .htaccess, to redirect all users that entered to a subdomain to the main domain to a specific php file? for example, if you enters to http://mypage.example.com/, so you'll rediract to http://example.com/website.php?name=mypage&using=subdomain. If you'll type http://mypage.example.com/contact.php, you'll rediract to http://example.com/website.php?name=mypage&page=contact&using=subdomain and if you'll type some additional info (?action=send#buttom) it will stay (if I'm not mistaking, [QSA])
Thank you, but I just used Wild Card (I'm not sure that it is the name). What is does it is when you write a subdomain, no metter what subdomain, it redirects you to the main domain, and then using .htaccess I continued...
I currently have a WordPress Multi-Site Network set up. The main website is located at "http://safesideinc.com." Then, there is another sub-domain "http://danielgosek.safesideinc.com."
I want the URL "http://safesideinc.com" to lead to "http://safesideinc.com," and the URL "http://danielgosek.com" to lead to "http://danielgosek.safesideinc.com."
Using a 301 Redirect in .htaccess, I can achieve this. However, I would like it so that entering "http://danielgosek.com" in the URL bar leads to "http://danielgosek.safesideinc.com." WITHOUT CHANGING the URL displayed--in this case, the displayed URL should remain "http://danielgosek.com."
Are there any rules that could help me achieve this?
Not possible, a 301 - Permanent Redirect, is an instruction to the BROWSER that the resource has moved permanently and the BROWSER should re-direct to the provided new URL.
If you don't want the URL to change you either need a Reverse proxy set-up between the two virtual hosts / domains, or if danielgosek.com is just an alias, same IP and served from the same Apache virtual host, you could use an internal rewrite.
I have a parked domain www.my-domain.com
I also have a hosted active domain sub.active-domain.com
I want to forward www.my-domain.com to sub.active-domain.com but keeps the url on
structure in the browser from sub.active-domain.com
example:
sub.active-domain.com/content/market.html
will shows on url become
www.my-domain.com/content/market.html
how to do it thru the htaccess file ? or should i do it thru the DNS or CNAME ?
The best way would be with .htaccess.
But you can not keep the url as long as you redirect it somewhere.
Or other wise use a iframe.
I have register a new domain name (example.com.sg) without hosting server, but my existing website (example.co.uk) has hosting server with all scripts, content, and database.
How to pin point my new domain name to current website in [example.co.uk]'s htaccess file?
Or any other way to redirect that page when visitor type the URL domain name (example.com.sg) in browser and goes to my website (example.so.uk) ?
I'm not sure what you're wanting to do, but if you don't have a hosting server for a domain, you will not be able to have a .htaccess file (since it would need to be hosted) and therefore would not be able to redirect in that fashion.
Like I said though, I don't really understand what you're asking.
However, a redirect from one domain to some other would look like this:
Redirect 301 / http://example.co.uk/
That would send all hits to the root directory to example.co.uk.
This is what domain parking do. Go to the cpanel of your example.co.uk site and select parked domains. Then park example.com.sg on example.co.uk