$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>htaccess - main-domain of wordpress keep redirecting to subdomain|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

htaccess - main-domain of wordpress keep redirecting to subdomain

matteradmin8PV0评论

I was in process of deploying my wordpress website mysite/NewSite to mysite during the deployment I messed up something and my main site has started redirecting from mysite to mysite/NewSite.

I have deleted everything from root folder, checked cpanel redirects section etc but everything looks fine. I also created .htaccess file under public_html folder but still no luck.

# BEGIN WordPress
<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

I know this more kind of a descriptive question. This is kind of super urgent as site is down which an issue. You help is required.

I was in process of deploying my wordpress website mysite/NewSite to mysite during the deployment I messed up something and my main site has started redirecting from mysite to mysite/NewSite.

I have deleted everything from root folder, checked cpanel redirects section etc but everything looks fine. I also created .htaccess file under public_html folder but still no luck.

# BEGIN WordPress
<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

I know this more kind of a descriptive question. This is kind of super urgent as site is down which an issue. You help is required.

Share Improve this question edited Nov 19, 2018 at 22:28 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Nov 19, 2018 at 22:26 Aamir ShahzadAamir Shahzad 1232 silver badges7 bronze badges 2
  • @fuxia I have checked wp-options and everything looks good there... when I install a fresh copy of wordpress... mysite/wp-admin is accessible and all of its settings but as soon as I hit mysite it redirects to mysite/NewSite – Aamir Shahzad Commented Nov 19, 2018 at 22:42
  • What is the significance of "NewSite"? Is it the actual directory where WP is installed? Was it only used in development? Was it only used on the development server? You use "subdomain" in the title, however, example/NewSite is a subdirectory, not a subdomain? What response do you get from example/NewSite? Have you confirmed this is an external 3xx redirect? What status code are you seeing: 301, 302, 3xx? Or do you get a 200 response (which indicates a client-side redirect)? – MrWhite Commented Nov 20, 2018 at 9:01
Add a comment  | 

2 Answers 2

Reset to default 1

According to the Codex instructions:

https://codex.wordpress/Changing_The_Site_URL

If you add these defines to your wp-config.php

define( 'WP_HOME', 'http://example' );
define( 'WP_SITEURL', 'http://example' );

These will override the options saved in your wp_options table, you should then remove the /NewSite suffix from your General Settings page. (Or if wp-admin is accessible now you may be able to just do that already.)

Alternatively you could edit the database directly and change the home and siteurl values in wp_options and that will achieve the same thing.

I've never liked changing the domain name within the wp-settings.php file. I always change it directly in the wp-options table (in two places)...since that is where it will be defined (and read from in Settings). My theory is why not change it in the original spot (the wp-options table) rather than adjusting the values in the wp-settings file.

So, my first thing would be to remove those values from wp-config.php, then make sure the proper URL is in the wp-options table. And then to use a standard htaccess file according to the codex. Make sure you supply the full URL, with the protocol (as in https://www.example ).

Changing the permanlinks value will sometimes rewrite the htaccess file, but I always just use the standard htaccess from the Codex.

Post a comment

comment list (0)

  1. No comments so far