Moving Wordpress pages from subdirectory to root - php

Beginner mistake, but I've created all my new pages for my Wordpress site in a subdirectory to my original site, and now I wish to move all the pages I've made to my root directory in order to sort the URL to my website.
At the moment my new pages are stood in
www.mysite.com/wordpress-4.6.1/wordpress/
when I enter my site via browser. I've looked around here for advice and tried all that I can find, but nothing seems to solve my problem for some reason. I've tried to change the URL explicitly under the Wordpress general settings but that just crashed my website somehow, so I had to redefine WP_HOME and WP_SITEURL in wp-config.php in order to get it up and running again. I've since tried downloading .htaccess and index.php and changing a few lines in index.php and then placing them in the database root.
The problem I'm left with now is that when I set the URL explicitly in wp-config.php I can't change it under 'General Settings' in Wordpress anymore, and if I state the URL that I want explicitly in wp-config.php the site stops working.
What would you guys suspect is the culprit here? Why is it that I can't change the URL explicitly and get it to work, are there some database-stuff that's still pointing at my wordpress folders or do you think it's something else?
Sorry for the wall of text, but couldn't seem to formulate it any shorter. Immensely thankful for any help!

This is covered in the Wordpress documentation: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

You will need to change the URL on option table of database.

I managed to work it out! Since I couldn’t edit the Wordpress URL and Site URL directly in Wordpress I had to add this code to wp-config:
define('WP_HOME','http://mydomain.se/wordpress-4.6.1/wordpress');
define('WP_SITEURL','http://mydomain.se/wordpress-4.6.1/wordpress');
I assumed that I had to remove the /wordpress-4.6.1/wordpress from the WP_SITEURL since the “Site Address (URL)” is what I would have changed in Wordpress if it had been possible. Since that didn’t work I removed the subfolders from WP_HOME URL instead and left them on WP_SITEURL and that solved the problem!

Related

Wordpress Redirect wp-admin to wp-admin/wp-login.php

Im using Local by Flywheel for test a WP site, I import a DB and change the URL with the Local URL.
But, when im try to my admin, the site redirect..
http://example.com/wp-admin/example.com/wp-login.php?redirect_to=http%3A%2F%2Fexample.local%2Fwp-admin%2F&reauth=1
I dont know why this happen, ill try everything, for example, add the URL to wp-config.php
define('WP_HOME','example.local');
define('WP_SITEURL','example.local');
also clean my cookies, try another browser, but still having that problem.
Any idea how tho fixed?
As i see - it tries to find wp-login.php under /wp-admin/example.com/,
not /wp-admin/.
example.com/wp-admin/example.com/wp-login.php
Check .htaccess file.
Probably some routing issues.
Maybe regenerate it.
Check permalink inside the wp admin cms. Change permalink to 'post name' to change 'plain' and then save. Now try (or) check .htaccess file us well.

WP-Admin redirects to old URL (after editing config.php)

I am trying to get a client's WordPress site copied over to my company's server to use as a development site. I've ran into an issue when trying to log into the site's administrator panel; it redirects us to the existing site's URL instead (ending up as [OLD SITE]/[NEW URL]/wp-admin). Additionally, trying to go to any page other than the homepage gets a 404.
I've tried editing the wp-config and defining the WP_HOME and WP_SITEURL there, with no success. In a previous attempt we used a backup tool that was meant to replace references to the old URL with the new URL, and on another we ran queries and checked through wp-options in the database to be sure that we caught all of the old references. Still redirects to the old site.
We've tried restoring from two backups, Akeeba and BackUpWordPress. Our current attempt is a copy we've downloaded directly and then uploaded (with an imported SQL backup).
Another odd thing I've noted is that changing one of the URLs in the database causes more issues. Mainly, if I update the URL of 'wordpress-https_ssl_host' in the wp-options table, the theme breaks. Not sure where to go with this from here.
I'm always succesfully using the following script : search & replace:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
in order to update a wordpress site url.
Just copy the provided code in a directory under your site, then launch the provided index.php in a browser: the database infos should be automatically determined. Then specify the old and new urls and click on "Run" !
Don't forget to remove the created directory afterwards.
For solving this issue you have to change siteurl in database wp_options table
option_name = siteurl where
option_value = YOUR OLD SITE URL
change your old site url and update it with your local developement site URL
Hope this will help you..
We found the problem; as it turns out it was nothing to do with anything from the default WordPress files. The client was using an extension called WordPress HTTPS, and apparently that was causing a conflict somewhere. We renamed the extension's folder to disable it and everything ran fine. I imagine it was overriding what we were setting in wp-config.

What causes a wordpress homepage to load

UPDATE: Real links below to illustrate my issue.
Stick with me on this, because it is a valid question.
In the old days I could have danhoover.org which was a wordpress site and I could have danhoover.org/new which was another wordpress site and both would load fine. I could even point danhoover.net to the danhoover/new directory and the page would load just fine no matter how you got there. You could use danhoover.org/new or danhoover.net and it would load fine. All the permalinks would work. No problem.
Now, however, there is some sort of voodo going on. If a wordpress site is in the danhoover.org/new folder and configured to be "danhoover.net", navigating to the folder as danhoover.org/new will just get you a 404 error.
In addition, going to danhoover.org/new/index.php will get you a 404 error.
There is some sort of voodoo going on that makes you use the url defined in the configuration for the site to work properly. What is it? Is there any way to manually update the permalink structure so it loads properly with either domain?
I guess I'm just confused as to what in the world wordpress is doing that is different than any other php site that prevents it from loading.
UPDATED LINKS:
I have a folder /a which has campscoreboard.net pointed to it.
I have a folder /a/c which has www.c.campscoreboard.net pointed to it.
Wordpress links:
You can go to www.campscoreboard.net/c and the homepage loads
You can go to www.c.campscoreboard.net and the homepage loads and all
the links work.
But if you go to www.campscoreboard.net/c and click on a link like the
Hello World article, you're redirected back to the root for some
reason.
Vanilla PHP Links
You can go to www.campscoreboard.net/c/test.php and it loads fine.
You can go to www.c.campscoreboard.net/test.php and it loads fine.
Only the wordpress urls are redirecting back to the root when loaded via www.campscoreboard.net/c
I've not tried to install WordPress inside WordPress before, but ...
In the wp-config.php file of the relevant WordPress installation, you can set the correct URL and HOME directory manually using:
define( 'WP_HOME', 'http://danhoover.org/new/' );
define( 'WP_SITEURL', 'http://danhoover.org/new/' );
I usually add these after define('WP_DEBUG', false);
Hopefully this helps.
This shouldn't be related to the home configuration as all that would do is forward you to danhoover.org, not give you a 404.
This is likely a server permissions issue where your server is blocking access to the folders. This can be set either on the servers main config file (e.g. httpd.conf) or in a .htaccess file which can be placed in any folder to which one wishes to change its (/subfolders') permissions.
You can read some more here.
A quick way to help you diagnose this, create a static html file and place it in danhoover.org/new call it index.html and place some text in the file then load danhoover.org/new in your browser and see if the text you've written in the file appears, if not then you know it's a server/permissions issue, not a Wordpress one.

Wordpress issue - siteurl and home option is being changed every time I log into the admin

I hope you can help me.
For some unknown reason, every time I log into the admin and update the site, afterwards the "siteurl" and "home" paths are always changed to a previously used "testsubdomain". I already hired a developer who gave up telling me that he isn't a Wordpress specialist and can't see where the issue is.
What I have done until now, I just went into the phpmyadmin every time I noticed that it happened again, and changed the entries back to its correct path manually. This has become a real pain because every time this happens, the contact form entries aren't forwarded to the client either, and he is losing potential business.
Can anyone help and point me into a direction of how to fix this?
The site is http://www.chinatownband.com.
Thank you in advance!
Check to see if the URLs are hardcoded in either wp-config.php or the active theme functions.php file. Those are locations that read the URL settings for WordPress and can be used to fix or hardcode the URLs because they will override the URL settings in the database (see http://codex.wordpress.org/Changing_The_Site_URL ).
You're looking for
define('WP_HOME','http://testsubdomain.com');
define('WP_SITEURL','http://testsubdomain.com');
If you find those, delete them and then change to http://www.chinatownband.com in the database with phpmyadmin as you have been doing.
If those settings are not in wp-config.php or the active theme functions.php file, download the whole theme and use a text editor to search the folder for those define lines.
And look in the root web directory for any non-core WordPress files and folders and check them, too.
In the end, you may also need to use https://github.com/interconnectit/Search-Replace-DB to safely find/replace URLs in the database. The URLs you are changing are only the 2 settings URLs and don't retroactively change any URLs in page/post content that are links to media, other pages, etc.

Homepage not loading, all other pages loading in WordPress migration

Nobody has had this problem yet it seems.
I just migrated a small WordPress website from my test server-space on iPage over to a client's server on HostGator and while I am logged into WordPress on the new server - the website shows up fine, but if I clear my cache and come on as a new user (as my boss did) they find the silly 2014 theme with no content. But if they go to a specific link it loads fine and then so does the homepage.
I have searched this topic extensively but found nothing. I have tried other migration problems' fixes such as:
adding a new php.ini
uploading new indexes to the root dir and theme dir
saving permalink settings again, and then changing and saving again
updating WP version
deactivating plug-ins
changing .htaccess lines
Why was it working perfectly on the old server location but not the new?
Y'all are my last resort. Is there some sort of cache error (or normal activity that needs overriding) going on? .htaccess? index.php? Is it HostGator's servers maybe?
Please help!
UPDATE: A combination of changing the site/home url in WP_Options and re-saving the permalinks fixed this issue for me.
One of the reasons why wordpress urls contained in the BD pointing to the url old, running this script in phpmyadmin can solve:
UPDATE wp_options SET option_value = REPLACE(option_value,'old_site','new_site');
UPDATE wp_posts SET post_content = REPLACE(post_content,'old_site','new_site');
UPDATE wp_posts SET guid = REPLACE(guid,'old_site','new_site');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value,'old_site','new_site');
Also exist the possibility that your hosting account contains a folder with your username, in the wp_options table may be included, for example upload_path: /home/[folder_old_id]/public_html/wp-content/uploads
UPDATE wp_options SET option_value = REPLACE(option_value,'folder_old_id','folder_new_id');
The behaviour you describe is not what I am seeing "But if they go to a specific link it loads fine and then so does the homepage.":
I get the same result following a home link as typing the URL so this is simply a configuration issue
Try this:
rename any .htaccess files .htaccess.temp
look directly in the wp_options table in the database to make sure all entries are correct
review the $site_url in php.ini
taking your test environment offline
This will eliminate most (all?) of the possible reasons your site is not behaving.
Good luck!
Hey I faced the same issue.
If you have just copied the Wordpress files for the mogration, check if you have copied the index.html file from your local site to your production site and delete it. This should fix the issue.
I actually ran into the same/ a similar problem. Homepage didn't work but subpages did. I solved it by looking through my files on the server (FTP) and renaming a mysterious "index.htm" to "index.htm.temp". Turns out wp took this index.htm as the default file for my landing page. Renaming and later deleting it solved the issue.
My website was migrated using the WP Duplicator PlugIn.
Well, if you consider your problem something someone "wants" to do, then you'll find a lot of resources... for example:
https://wordpress.org/support/topic/using-a-different-wordpress-theme-for-a-single-page
Apparently you can create a page template and have the template load a different theme then all the other pages on the site. You can theoretically have every page on your WordPress install run a different theme.
Check things like home.php, front-page.php and what not to see if the homepage is running a template.

Categories