I know that permalinks involve rewrite rules and they are somehow updated by Dashboard > Settings > Save changes. Sometimes this must be "refreshed" when you add plugins the create new re-write rules... but usually the .htaccess file doesn't change. So what is that button actually doing?
I know it tries to re-write the .htaccess file (if it has sufficient permissions on the server), but does it do something else? Is there a cache or database record somewhere as well?
For reference, here's the codex page for permalinks. (It only talks about .htaccess)
It also tells WordPress to write the form values to the options table for the following options:
permalink_structure
category_base
tag_base
The default permalink structures denoted by radio buttons simply have the structure pre-formatted for the user, so the Day and name option for example is simply written into the database as
/%year%/%monthnum%/%day%/%postname%/
The Default option is written into the database as an empty string to indicate not to use pretty permalinks.
Related
this may be too general question to ask, but how does wordpress permalink work?
clearly they dont work with htacces only what it seems?!
there is that page where a "template tree" is listed
"single.php"-url is like that: "https://example.com/thisisanarticle"
"page.php"-url is like that: "https://example.com/apage"
so how does wordpress know what to call? both urls share the same structure after all.
Under the hood, WordPress uses their WP_Rewrite mechanism to create/update entries in Apache's .htaccess file whenever permalinks are added/removed/updated.
The class and its implementation in the WordPress core use a set of rules to query the WordPress database and write the rules into .htaccess each time an update is determined to be required.
I want to uncheck the "organize my uploads into month- and year-based folders" option in my WordPress site, but a previous version of my site had that checkbox checked. There are links and other references to those folders in URLs throughout the site. Is there a way to globally update this? Or perhaps I can fix it with an .htaccess rewrite of some kind?
So that this:
https://example.com/wp-content/uploads/2018/04/catalog.pdf
Would need to become:
https://example.com/wp-content/uploads/catalog.pdf
I think Better Search Replace can handle globally updating image paths stored throughout the database (backup the database first for sure).
If everything is in /uploads, searching for '/uploads/XXXX/XX/' and replacing with '/uploads/' should suffice. You could redirect with wildcards in .htaccess but to me the data is still wrong and this approach only masks it.
Scratch the following:
Make sure the default Media Library location is set to the /catalog
folder going forward after unchecking the 'organize my uploads into
month- and year-based folders' in Wordpress if you haven't. In
wp-config.php, add:
define('UPLOADS', 'wp-content/uploads/catalog');
Edit: misread OP's original question.
i want to move my wordpress site from (alpha.domain.com) to (domain.com). i have already old website on domain.com which is in php . what should i do ? any changes need to be done in database? So need your advice.
As atinder has mentioned in the comments, see here for official instructions from Wordpress.org. However, I would like to highlight the key points:
You need to move backup your files and database firstly, via cPanel/FTP/pointing the new URL to the correct directory. (this is the easy part)
Once you have moved them to the correct location, you will need to do the following to make sure that your URLs are correct:
Update Base/Site URLs
In phpMyAdmin or your preferred MySQL database manager, go to the wp_options table and change siteurl and home to your new URL. These two options would usually be the first two rows in the table.
Update hardcoded permalinks
Depending on what themes and plugin you used, you will also need to update hardcoded URLs in your posts and options. I recommend backing up your database before doing a full search and replace (to replace old url with new url), as serialized data will break if you simply do a raw search and replace.
If you are certain your database doesn't contain serialized data in wp_posts.post_content, wp_postmeta.meta_value, wp_options.option_value (simply do a search first to confirm), you may safely proceed with an SQL query as outlined here. NOTE: AT YOUR OWN RISK!! BACKUP FIRST!!
You can see this section from the instructions for plugins that will help perform safer search and replace.
I changed my domain from http://www.troov.co/blog to http://www.troov.com/blog
Despite changing the Wordpress Address URL and Site Address URL to www.troov.com/blog, it's still trying to load resources from www.troov.co, and so none of the styling or images displays correctly.
I'm guessing there is a setting somewhere which I haven't changed, but unfortunately despite trying, I can't locate it!
Thanks in advance.
You need to find/replace URLs in the rest of the database, i.e. the wp_options table as a whole, the GUIDs of posts, etc., not only for the two main site URL options you changed (Wordpress Address URL and Site Address URL).
Don't do a find/replace in a text database dump; that will break serialized data, i.e. theme options, widgets, etc. You can do a find/replace in the database with queries using phpmyadmin or adminer, but that can still break serialized data.
You must use a tool that correctly de-serializes and re-serializes php data. Use WordPress Serialized PHP Search Replace Tool. It's very popular and works well.
Also check to see that the domain is not hardcoded in wp-config.php or the theme's functions.php file in the format
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Remove those directives, if found. See https://codex.wordpress.org/Changing_The_Site_URL
You have to change the main url from http://www.troov.co/blog to http://www.troov.com/blog in Admin Tool -> Settings -> General or directly in the wp_options table, check the option_value field for corresponding siteurl and home option_name field records.
Probably, you have your domain address hardcoded. You can check this in your theme files, how url for images are generated, etc.
It seems like an issue that has been talked about a large number of times, but for some reason, I can't seem to get it to work.
Goal: Change Wordpress site from example.com/wordpress to example.com/blog
Here is what I've tried:
Changed the Wordpress root folder from "wordpress" to "blog"
Then, in phpmyAdmin, changed the siteurl and home url's to example.com/blog
When that did not work, I also went into my theme's functions.php file and added:
update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');
immediately after the opening
<?php
tag.
Is there something I am missing?
When your domain name or URLs change - i.e. from http://example.com/blog to http://example.com, or http://example.com to http://example.net - there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.
If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:
1- Only perform a search and replace on the wp_posts table.
2- Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below )
Info taken from http://codex.wordpress.org/Moving_WordPress
Search and Replace for WordPress Databases Script: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
You need to update all URLs in your database too.
Take a look at this script:
http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
You could try this plugin:
http://wordpress.org/plugins/wp-migrate-db/
From its own description:
"Exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer."