Why is my subdomain redirecting to my www?
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.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.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
RedirectPermanent /about/press/
-
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. 0 -
Copying my existing database, updating the address of the database in the wp code, and then updating the site address in the database worked perfectly. Thanks so much! 0 -
Glad to see you were able to get the issue resolved. Thanks for updating here with what worked. 0 -
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 0 -
Any help regarding above content would be appreciated. 0 -
@AmirZ - since this is a WordPress site, have you updated the Siteurl value in the WordPress database to reflect the change? 0 -
@AmirZ - since this is a WordPress site, have you updated the Siteurl value in the WordPress database to reflect the change?
that was the step I did not perform. Cheers0 -
@AmirZ - I'm glad that helped! 0
Please sign in to leave a comment.
Comments
8 comments