permalinks - Add blog prefix for all WordPress front end url

admin2025-01-08  5

My WordPress installed in root directory www.example

I need home and site URL like below.

Site_url. www.example Home_url www.example/blog

I need prefix '/blog' for all frond end URL.

Please let me know how we can achieve this?

Is there any code level changes required for this?

I tried this and it is working, I am facing issue with w3 total cache plugin. Issue is CSS/JS minify not working. If both site and home URL same then only CSS/J's minify working.

Please suggest.

My WordPress installed in root directory www.example.com

I need home and site URL like below.

Site_url. www.example.com Home_url www.example.com/blog

I need prefix '/blog' for all frond end URL.

Please let me know how we can achieve this?

Is there any code level changes required for this?

I tried this and it is working, I am facing issue with w3 total cache plugin. Issue is CSS/JS minify not working. If both site and home URL same then only CSS/J's minify working.

Please suggest.

Share Improve this question edited Jan 5, 2019 at 1:55 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jan 5, 2019 at 1:36 Naveen BTNaveen BT 11 bronze badge 0
Add a comment  | 

2 Answers 2

Reset to default 0

First, go to your Permalinks settings in your Admin Panel > Settings > Permalinks, on Custom Structure you will see something like this:

So let’s add at the begining the word ‘/blog‘, it will look like this:

HOW TO ADD ‘/BLOG/’ IN FRONT OF YOUR URL

To achieve the desired setup where the site URL is www.example.com and the home URL is www.example.com/blog, you can follow these steps:

1. WordPress Settings:

  • Go to your WordPress dashboard and navigate to Settings > General.
  • Set the WordPress Address (URL) to www.example.com/blog.
  • Set the Site Address (URL) to www.example.com.

2. Move WordPress Files:

  • Move all the WordPress files and folders to the /blog directory.
  • Update the index.php and .htaccess files in the root directory to reflect the new path:

In index.php: require( dirname( FILE ) . '/blog/wp-blog-header.php' );

In .htaccess: RewriteEngine On RewriteBase /blog/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L]

3. Update Permalinks: In the WordPress dashboard, go to Settings > Permalinks and update the permalink structure. This will refresh the rewrite rules.

4. Update Site URL in Database: If you still face issues with plugins, you may need to update the site URL directly in the database. Use phpMyAdmin or a similar tool to execute the following SQL queries:

UPDATE wp_options SET option_value = 'http://www.example.com/blog' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://www.example.com' WHERE option_name = 'home';

5. Clear Caches: After making these changes, clear your browser cache and any caching plugins you are using.

W3 Total Cache: For W3 Total Cache issues, try the following:

  • Clear W3 Total Cache cache.
  • If minification issues persist, try turning off minification, clear cache, and then turn it back on.
  • Make sure the minified files have the correct paths after changing the site URL.

If the issue persists, you may need to check for any specific compatibility issues between the WordPress setup with a subdirectory and the W3 Total Cache plugin. Consider checking the plugin's support forums or documentation for any known issues or solutions.

Be sure to back up your site before making significant changes to ensure you can restore it if something goes wrong.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736267097a1173.html

最新回复(0)