How to Get Rid of /wordpress/ From Your WordPress Site URL

## Understanding Why “/wordpress/” Exists in Your URL
When you first install WordPress, especially if you’re using an auto-installer through your hosting provider, you might find that your website URL ends up looking something like `yourdomain.com/wordpress/`. This happens because the WordPress files are installed in a subdirectory named “wordpress” on your server. While functional, this isn’t ideal for branding, SEO, or user experience. Visitors generally expect to land directly on `yourdomain.com`, not a subdirectory. Removing `/wordpress/` makes your URL cleaner and more professional.
Preparing for the Change: Backups and Considerations
Before making any changes to your WordPress URL structure, it’s crucial to prepare thoroughly. A mistake during this process could render your website inaccessible.
* Create a complete backup of your WordPress website. This includes:
* Your WordPress files (the `/wordpress/` directory and all its contents)
* Your WordPress database (containing posts, pages, settings, etc.)
* Deactivate all plugins. Plugins can sometimes interfere with URL changes. You can reactivate them one by one after the process is complete and you’ve confirmed everything is working correctly.
* Choose a time when website traffic is low to minimize disruption to your visitors.
* Familiarize yourself with accessing your hosting account’s file manager or FTP client. You’ll need to move files and potentially edit configuration files.
* Understand the difference between moving the files and simply redirecting the `/wordpress/` URL to the root. While redirection is simpler, it’s generally not the recommended approach. We’re aiming for a permanent fix that removes the `/wordpress/` subdirectory from the URL altogether.
* If you’re using a caching plugin or server-side caching, clear the cache before and after making the changes.
Method 1: Moving WordPress Files Through the WordPress Dashboard
This is often the easiest method, but it requires that your WordPress installation is already accessible through the `/wordpress/` subdirectory.
- Log into your WordPress dashboard at `yourdomain.com/wordpress/wp-admin`.
- Navigate to **Settings > General**.
- In the **WordPress Address (URL)** field, change `yourdomain.com/wordpress/` to `yourdomain.com`.
- In the **Site Address (URL)** field, change `yourdomain.com/wordpress/` to `yourdomain.com`.
- Click **Save Changes**.
You’ll likely be logged out of your WordPress dashboard after saving. This is normal.
- Using a file manager (provided by your web hosting provider) or an FTP client (like FileZilla), log into your web server.
- Locate the `/wordpress/` directory.
- Move all the files from inside the `/wordpress/` directory (including `wp-config.php`, `wp-admin`, `wp-content`, `wp-includes`, and all other files and folders) to the root directory of your website. This is typically named `public_html`, `www`, or the name of your domain. **Do not move the `/wordpress/` directory itself, just its contents.**
- Open the `wp-config.php` file in the root directory with a text editor.
- Look for the line that defines the `DB_NAME` constant, the `DB_USER` constant, and the `DB_PASSWORD` constant. Make sure these values are still correct. This is crucial for connecting to your database.
- Save the `wp-config.php` file.
Now try accessing your website at `yourdomain.com`. If everything was done correctly, you should see your website. You can log into your WordPress dashboard at `yourdomain.com/wp-admin`.
If you encounter any errors, double-check that you moved all the files and that the database credentials in `wp-config.php` are correct.
Method 2: Using FTP/File Manager Directly
This method is used when you might not be able to access the WordPress dashboard initially.
- Using a file manager or an FTP client, log into your web server.
- Locate the `/wordpress/` directory.
- Move all the files from inside the `/wordpress/` directory to the root directory of your website. **Do not move the `/wordpress/` directory itself, just its contents.**
- Open the `wp-config.php` file in the root directory with a text editor.
- Look for the line that defines the `DB_NAME` constant, the `DB_USER` constant, and the `DB_PASSWORD` constant. Make sure these values are still correct.
- Save the `wp-config.php` file.
At this point, you might be able to access your WordPress dashboard at `yourdomain.com/wp-admin`. If you can, follow steps 2-5 in Method 1 to update the WordPress and Site Address URLs in the General Settings. If you *cannot* access the dashboard, proceed to the next step.
- Access your WordPress database using phpMyAdmin (usually accessible through your hosting control panel).
- Find the `wp_options` table (the prefix `wp_` may be different depending on your installation).
- Locate the `siteurl` option and change its value from `yourdomain.com/wordpress/` to `yourdomain.com`.
- Locate the `home` option and change its value from `yourdomain.com/wordpress/` to `yourdomain.com`.
Now try accessing your website at `yourdomain.com`. You should be able to access your website and log into your dashboard at `yourdomain.com/wp-admin`.
Method 3: Using WP-CLI (WordPress Command Line Interface)
This method requires command-line access to your server and familiarity with WP-CLI. It’s a more advanced method but can be faster and more efficient for experienced users.
- Connect to your server via SSH.
- Navigate to the root directory of your WordPress installation (the directory *above* the `/wordpress/` directory).
- Run the following WP-CLI command to update the `siteurl` and `home` options:
`wp option update siteurl yourdomain.com`
`wp option update home yourdomain.com` - Move all the files from inside the `/wordpress/` directory to the root directory. You can do this using command-line tools like `mv`. For example:
`mv wordpress/* .`
`mv wordpress/.* .` (This moves hidden files as well) - Edit the `wp-config.php` file to reflect the new location of the WordPress files. This step is crucial and often missed.
To avoid editing the wp-config.php manually, you can use the following WP-CLI commands to automatically update the WP_SITEURL and WP_HOME constants, though doing so is generally not recommended unless you know exactly what you’re doing, since these constants should ideally not be defined in wp-config.php.
Now try accessing your website at `yourdomain.com`. You should be able to access your website and log into your dashboard at `yourdomain.com/wp-admin`.
Post-Migration Tasks and Troubleshooting
After successfully removing `/wordpress/` from your URL, there are a few essential tasks to perform:
* **Permalinks:** Go to **Settings > Permalinks** in your WordPress dashboard and click **Save Changes**. This will refresh your permalink structure and ensure that your internal links are working correctly. Even if you don’t change the permalink structure, saving it is important.
* **Internal Links:** Use a plugin like “Better Search Replace” to search your database for any remaining instances of `yourdomain.com/wordpress/` and replace them with `yourdomain.com`. This ensures that all internal links point to the correct URLs.
* **External Links:** Check your Google Analytics and Google Search Console accounts for any broken links or errors. Update any external links that point to your old URL.
* **Robots.txt:** Review your `robots.txt` file to ensure that it’s not blocking any important content.
* **Sitemap:** Regenerate your sitemap and submit it to Google Search Console.
* **Caching:** Clear your website cache (if you’re using a caching plugin) and your browser cache.
* **Plugin Conflicts:** Reactivate your plugins one by one, checking your website after each activation to ensure that there are no conflicts.
**Common Issues and Solutions:**
* **”Error establishing a database connection”:** This usually indicates a problem with your database credentials in `wp-config.php`. Double-check the `DB_NAME`, `DB_USER`, and `DB_PASSWORD` constants.
* **Website redirects to `yourdomain.com/wordpress/`:** This often means that the `siteurl` and `home` options in the `wp_options` table are still set to the old URL. Use phpMyAdmin to update them.
* **Images and other media are broken:** This can happen if the URLs in your database still point to the old `/wordpress/` directory. Use the “Better Search Replace” plugin to update them.
* **”404 Not Found” errors:** This is usually a permalink issue. Go to **Settings > Permalinks** and click **Save Changes**.
* **Website is displaying a blank page:** This could be due to a plugin conflict or a problem with your theme. Try deactivating all plugins and switching to a default theme (like Twenty Twenty-Three).
* **Admin dashboard CSS is broken:** Clear your browser cache. Sometimes, the browser still loads old CSS files from the `/wordpress/` directory.
Redirecting Traffic: A Temporary Solution (Not Recommended as Primary Fix)
While moving the files is the preferred method, a 301 redirect can be used *temporarily* if you’re having trouble with the file movement. However, this is not a long-term solution, as it will slow down your website and isn’t ideal for SEO.
You can add the following code to your `.htaccess` file (located in your root directory) to redirect traffic from `yourdomain.com/wordpress/` to `yourdomain.com`:
“`
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^wordpress/(.*)$ /$1 [R=301,L]
“`
**Important:** This code should be placed *above* any WordPress-specific directives in your `.htaccess` file.
**Note:** Modifying .htaccess incorrectly can break your site. Always back up your .htaccess file before making changes.
Again, using a 301 redirect is a workaround, not a solution. The best approach is to move the WordPress files and update the database settings as described in the previous methods.
Conclusion
Removing `/wordpress/` from your WordPress website URL is a worthwhile effort that improves your website’s professionalism, SEO, and user experience. By carefully following the steps outlined in this article and taking the necessary precautions, you can successfully remove the subdirectory and have your website accessible directly at your domain name. Remember to back up your website, proceed with caution, and test thoroughly after making any changes.