Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
   Glossary   Glossary
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Author Topic: Webserver redirect from www. to / or the reverse  (Read 3808 times)

Weaver

  • Senior Kitizen
  • ******
  • Posts: 11459
  • Retd s/w dev; A&A; 4x7km ADSL2 lines; Firebrick
Webserver redirect from www. to / or the reverse
« on: August 06, 2020, 12:18:41 AM »

I’m just setting up a webserver at AA, I’ve emailed them with a few questions. If I try to do an http GET by hand using telnet to port 80, I can get the http response that I want if I include a "www." in the request. Without the www, I get an error response.

When I’ve tackled this kind of things before I used .htaccess and mod_rewrite to redirect www to / or the other way round, I can’t remember. I will ask AA if users are allowed to use .htaccess files.

What do you think is the best way of dealing with the www or nothing issue in general?

AA has a web page dealing with this and giving a solution. However I don’t have a webpage on that webserver; all I have is an http 301 redirect to another domain on a different server and that has been implemented with an index.http and a Location: field as according to AA’s support note. That all works, the redirect, but only if www is specified.

On the DNS server I’ve done a redirect for www. to the same webserver by using a CNAME. But as far as what’s going on without the www, I’m lost.

It’s so long, 15 years ago since I last set this up on a server, so I just can’t remember the details, but the power of .htaccess makes it easy to do anything.
« Last Edit: August 06, 2020, 12:26:26 AM by Weaver »
Logged

Alex Atkin UK

  • Addicted Kitizen
  • *****
  • Posts: 5261
    • Thinkbroadband Quality Monitors
Re: Webserver redirect from www. to / or the reverse
« Reply #1 on: August 06, 2020, 12:45:13 AM »

The virtual host for your site needs to actually be looking for the domain with and without www, so it depends how its been configured.
eg how mine is configured
Quote
ServerName csdprojects.co.uk
ServerAlias www.csdprojects.co.uk
« Last Edit: August 06, 2020, 12:51:32 AM by Alex Atkin UK »
Logged
Broadband: Zen Full Fibre 900 + Three 5G Routers: pfSense (Intel N100) + Huawei CPE Pro 2 H122-373 WiFi: Zyxel NWA210AX
Switches: Netgear MS510TXUP, Netgear MS510TXPP, Netgear GS110EMX My Broadband History & Ping Monitors

Weaver

  • Senior Kitizen
  • ******
  • Posts: 11459
  • Retd s/w dev; A&A; 4x7km ADSL2 lines; Firebrick
Re: Webserver redirect from www. to / or the reverse
« Reply #2 on: August 06, 2020, 01:53:53 AM »

I think I’ve just solved it. When I FTPed into the server the username I used was "www.example.com" (sic) yes, the same as the domain name for the site. That’s how the virtual server identifies which virtual host you are being, but there’s more - it also controls the directory at which you land and in which you are jailed, so if I log in with username just "example.com" without the www, I appear in a directory one level higher and am looking down upon a directory called www. I never knew this; I was in the www sub directory before and didn’t know it. So it turns out that I have to do the index.http thing in the directory one level higher instead or as well not sure which - not sure yet whether I have to put the same file in the upper level and in the subdir www to get things to work with and without the www. It may be that just the upper level will suffice, or it may be I have to put two copies in place - I could soon test that.
Logged

Alex Atkin UK

  • Addicted Kitizen
  • *****
  • Posts: 5261
    • Thinkbroadband Quality Monitors
Re: Webserver redirect from www. to / or the reverse
« Reply #3 on: August 06, 2020, 06:29:27 AM »

Its strange but perhaps its a way for you to be able to easily add sub-domains without them doing more configuration?
Logged
Broadband: Zen Full Fibre 900 + Three 5G Routers: pfSense (Intel N100) + Huawei CPE Pro 2 H122-373 WiFi: Zyxel NWA210AX
Switches: Netgear MS510TXUP, Netgear MS510TXPP, Netgear GS110EMX My Broadband History & Ping Monitors

d2d4j

  • Kitizen
  • ****
  • Posts: 1103
Re: Webserver redirect from www. to / or the reverse
« Reply #4 on: August 06, 2020, 08:19:37 AM »

Hi

Sorry you have totally confused me

@weaver - are you using a dedicated server from aa and setting up a web server or is this just a website on an aa webserver

I have no idea what index.http is or perhaps it just another name for a service

If using 2 different ftp credentials and each go to different locations specifically then I would think you have set these credentials up and told them the directory to goto

I would also advice using domain.url and www.domain.url as users is not secure and easily guessed (as is ftp.domain.url), so I would change them

Htaccess - I always believed if you had a htaccess file in root hosting folder, this is global to the hosting folders unless there is another htaccess in a hosting folder, at which point the global htaccess changes to the new htaccess found in the hosting folder

You may also want to review your hosting control panel, as you should be able to change php versions etc...

Many thanks

John
Logged

Chrysalis

  • Content Team
  • Addicted Kitizen
  • *
  • Posts: 7382
  • VM Gig1 - AAISP L2TP
Re: Webserver redirect from www. to / or the reverse
« Reply #5 on: August 06, 2020, 12:31:44 PM »

now days its standard to have the vhost configuration work with and without www, www subdomain is kind of considered legacy now days.  vhost configuration is something handled by the admin of the server in question (or the control panel if it has one e.g. directadmin or cpanel).

htaccess can work around it with redirects.
Logged

Weaver

  • Senior Kitizen
  • ******
  • Posts: 11459
  • Retd s/w dev; A&A; 4x7km ADSL2 lines; Firebrick
Re: Webserver redirect from www. to / or the reverse
« Reply #6 on: August 07, 2020, 03:38:41 AM »

> @weaver - are you using a dedicated server from aa and setting up a web server or is this just a website on an aa webserver

It’s the latter, not a dedicated server.
Logged