Hi, I have a problem with my domain. Ok I have my original site (call it mainsite .) and a second site (call this secondsite .). All the files for second site are stored in a subdomain of the mainsite.

When people access the site using a straight forward domain () everything is fine, when they access a folder with a forwardslash on the end () everything is fine.

BUT when they access a folder without a forwardslash () then they get redirected to the subdomain

This is the subfolder in which the site is stored....

Now is the problem because the domain is redirecting to a subdomain or something else?

Thanks in advance!!

Dani AI

Generated

As and hinted, this is almost always a server-side name/vhost issue rather than a browser bug. What happens: when the server sees a request for /folder it recognizes that folder is a directory and issues a redirect to the canonical directory URL (/folder/). That redirect is built using the server’s idea of the site name — if the request is being handled by the wrong VirtualHost or the server is configured to use its ServerName for redirects, the Location header will point to the subdomain you described instead of www.secondsite.co.uk.

Quick checks to run (copy results when you contact support):

curl -I http://www.secondsite.co.uk/folder

Look at the Location: header returned and the response code. Also inspect the webserver access log for that request to see which vhost served it (the Host header recorded) — that proves whether the second domain is matching a dedicated vhost.

Likely fixes to apply

  • Ensure www.secondsite.co.uk has its own VirtualHost (ServerName/ServerAlias) whose DocumentRoot is the second-site folder.
  • Set UseCanonicalName Off so Apache uses the client Host header when it builds redirect URLs (instead of the server’s ServerName). See Apache docs on UseCanonicalName and DirectorySlash for background.
  • If on shared hosting, make sure the domain is configured as an add-on (or separate) domain and not parked/aliased on the main site — otherwise requests will be served by the main vhost and redirects will use that host.

Relevant references: UseCanonicalName docs, DirectorySlash behaviour, VirtualHost basics.

If there is no server access, include the curl -I output and the exact redirect Location when you contact the host; that gives them everything needed to correct the vhost or hosting setup.

Recommended Answers

All 2 Replies

Its probably something wrong with the 'htaccess.txt' or the 'httpd.conf'. Check the files out. If you don't have access to them or don't know what you doing, send an email to your host and they should solve it for you within the a couple of hours

When you buy your domain you have to get it pointed to your web space and it is usually pointed to a file called index.php or something similar in the root. I think you need to point your second domain to another index file in the folder for your second site which is also in the root of your web space where the first site is. You can usually do this yourself if you have a control panel to access your web space.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.