SOLVED Why is my subdomain redirecting to my www?

coherent

Registered
Sep 16, 2020
2
1
3
Chicago
cPanel Access Level
Root Administrator
Hi there,
I am trying to create a staging Wordpress server that is a copy of an existing site I have running on the root and www domain. I created a new sub-domain staging.mysite.com and I can see in my domain registrar that I have a staging A record that is indeed pointing at my server.

The problem is when I actually go to the site. I get a 301 redirect when I go to staging.mysite.com that redirects to www.mysite.com. When I go to cpanel though I have no redirects on the redirects page and on the subdomains page, it says that my staging.mydomain.com does not have any redirects.

How I copied the site was download a zip of my current website and do a find and replace for all www.mydomain.com and replace it with staging.mydomain.com. These changes were all almost exclusively in the .htaccess file. Here's an example of what the .htaccess looks like:

```
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RedirectPermanent /about/press/ http://staging.mysite.info/sitemap
# there are hundreds of more redirects like this for every page on the site, all of them were updated to staging.
```

Any things to double check? I can't tell if this is a configuration with some kind of access file in the site folder or if there is a configuration parameter with cpanel.

Thank you!
 
Last edited by a moderator:

andrew.n

Well-Known Member
Jun 9, 2020
982
363
63
EU
cPanel Access Level
Root Administrator
Also re-write the URL in the WP database. If you go to general settings you will see that WP also stores the domain inside it's db. If you copy the site that needs to be changed as well.
 

AmirZ

Member
Feb 3, 2021
11
0
1
canada
cPanel Access Level
Website Owner
I came across this post from searching the forum and I have similar problem with a slight twist.

subdomain is created. design.domain.ca
database created and user is set to the database for the subdomain
Using file manager i have extracted the zip file and copied the files into subdomain folder which is in root. Not public_html
a copy of main domain database was exported and than imported into subdomain database
wp-config file set to connect to sub-domain.

When i visit the url for sub-domain. It will redirect me to domain.ca
i have checked to see if there is anything in redirect section inside cpanel and there is nothing.

What am i not performing correctly?

Thank you in advance