How to get rid of /WordPress/ From your WordPress Site Url? Are you facing issue in removing /wordpress/ from your site’s URL? Sometimes beginners end up WordPress installation in sub directory, which causes /WordPress/ to appear in their site url. Accidentally if you have installed WordPress in sub directory instead of root directory and want it to move in root directory then you are landed at the correct place. In today’s post we will show you how to get rid of this issue and remove /WordPress/ from your website url.
Why you see /wordpress/ in website url?
WordPress is fast easy to install and nowadays hosting companies also offer one click quick installation of WordPress through cpanel. Some beginners who manually install WordPress may end up accidentally installing WordPress in sub directory. Mostly this subdirectory named as wordpress.
Removing /wordpress/ from WordPress site url:
If you just have installed WordPress and there is no content on your site then just go ahead and start over.
Simply delete current installation & follow instructions to properly reinstall WordPress. If you already have content to your site then there are two methods to do so and remove /wordpress/ from your site url.
How to get rid of /WordPress/ From your WordPress Site Url?
Method 1:- Change WordPress Site Address
If you have an established WordPress site then this method is fast and easy. The only drawback of this method is that media files like images will still use /wordpress/ in their url.
Initially you need to login to your site’s admin area and navigate to settings-> General pages. Here you notice WordPress address and Site address fields both have same url. You need to make changes in site address option and point to your root domain url and leave wordpress address option as it is. After doing this tap on save changes button to store settings.
Now you have to connect website using FTP. Once you are connected navigate to /wordpress/directory and download .htaccess & index.php files to your computer. If you are unable to locate .htaccess file then you need to force FTP client to show hidden files. If you are using Filezilla then you need to click on server from menu bar and select “Force Showing Hidden Files” option.
Once you download both files to your desktop, you need to open index.php file in notepad++ or other code editor. In this file you find a code like
require(dirname(__FILE__) . ‘/wp-blog-header.php’);
this line loads up wp-blog-header.php file which required to load WordPress site.
Now what you have to do is to enter correct location of file by replacing existing line with this one:
require(dirname(__FILE__).’/wordpress/wp-blog-header.php’);
save changes and upload both index.php & .htaccess file from desktop to root of your domain using FTP. Root folder is the parent folder with wordpress folder inside it usually called /www/ or /public_html/
That’s all. Now you can visit your site using root domain and everything works fine.
Method 2:- Move WordPress to Root Directory
Step-1:- create duplicator package
At first, you need to install & activate duplicator plugin on your website. After activation, you have to visit Duplicator-> settings page and click create new button. This will launch Duplicator wizard, which creates an installer package of complete website. Click on the next button to continue. Next plugin will run some scans. If everything looks fine then click on build button.
Duplicator will create package and prompt to download it along with installer script. Go ahead and download both files to your system.
Step 2:- create new database for fresh WordPress install
You can use existing WP database but it’s better to create new one so that your old database us safe and unchanged. This way you can revert back to your site without much complications if something goes wrong.
Visit cPanel dashboard, scroll down to ‘Databases’ section and then click on ‘MYSQL Databases’ icon.
After that provide a name to your database and click create database button.
Now Cpanel creates a new database for you. After that you need to scroll down to MySQL users section. Here you need to provide username & password for new database use & click on create a user button. Now you have to assign database permission to new user.
Scroll down to ‘Add users to database’ section. Select database user you have created from dropdown next to user field and then select the database and click add button.
Now your new database is ready to use for fresh database installation.
Step 3:- Run Duplicator Wizard
You need to upload duplicator archive package and installer file you downloaded earlier to root directory. This is the directory containing /wordpress/ folder. After uploading both files, open installer script in browser window. You need to enter website’s root url and then prefix it with /installer.php. this will open duplicator installer wizard.
Check terms and conditions box and then click on next button to continue. Next, it will ask to provide database information. Enter required information for database we created in step 2.
After entering database info, click on next button. Duplicator will now unpack your WP Database backup from archive into new database.
Next it will ask to update site url and path. You don’t need to make any changes here as it automatically detect new url & path. However if it doesn’t then you can enter it manually.
Duplicator will now finish migration and you will be able to click on admin login to access website on new location.
Step 4:- Set up Subdirectory to root folder redirects
Your site is now moved to root directory from subdirectory. Now its fine to setup redirects so your users and search engines can find new location of your site.
Initially you need to connect your site to WordPress using FTP client then delete old /wordpress/ folder.
After that switch to WordPress admin since you need to moved it to root of your site WordPress admin url will like this https://example.com/wp-admin
Now install & activate redirection plugin, upon activation visit Tools>> Redirection page. Then plugin will now show a setup wizard. Simply click continue setup and then finish setup button.
Now switch to redirects tab and add new redirect. First check the ‘Regex’ checkbox at corner of first field. After that for source url add- https://example.com/wordpress/.* and for target url add https://example.com/$1.
Don’t forget to replace example.com from your own domain. Click on add redirect to save changes. That’s all from now all users access your website with /wordpress/ in the url will automatically redirected to correct post with new root url.