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 646 times)

Weaver

  • Senior Kitizen
  • ******
  • Posts: 10017
  • Retd s/w dev; A&A; 3x7km lines; Firebrick; IPv6
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

  • Kitizen
  • ****
  • Posts: 2943
    • 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
INTAKE (ECI) 2xHome Hub 5A (OpenWRT) on Zen & Plusnet, 1xHauwei H122-373 on Three 5G Router: pfSense (i5-7200U) WiFi: nanoHD (OpenWRT) + Honor Router 3
My Broadband History & Ping Quality Monitors

Weaver

  • Senior Kitizen
  • ******
  • Posts: 10017
  • Retd s/w dev; A&A; 3x7km lines; Firebrick; IPv6
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

  • Kitizen
  • ****
  • Posts: 2943
    • 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
INTAKE (ECI) 2xHome Hub 5A (OpenWRT) on Zen & Plusnet, 1xHauwei H122-373 on Three 5G Router: pfSense (i5-7200U) WiFi: nanoHD (OpenWRT) + Honor Router 3
My Broadband History & Ping Quality Monitors

d2d4j

  • Kitizen
  • ****
  • Posts: 1054
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: 6594
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
AAISP - Billion 8800NL bridge & PFSense BOX running PFSense 2.4 - ECI Cab - LINE STATISTICS CLICK HERE

Weaver

  • Senior Kitizen
  • ******
  • Posts: 10017
  • Retd s/w dev; A&A; 3x7km lines; Firebrick; IPv6
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