You can install WordPress into a subfolder such as /m instead of the web root (/public_html) and configure it to work properly either:
-
From the subfolder itself (
https://example.com/m), or -
From the root domain (
https://example.com), even though it's physically located in the subfolder.
This article explains both methods.
Option 1: Access WordPress from the Subfolder URL (https://example.com/m)
Step 1: Upload WordPress to a Subfolder
Place all WordPress files inside a subfolder under your root directory.
Example path: /public_html/m/
Step 2: Set WP_SITEURL and WP_HOME
Edit your wp-config.php file and add the following lines before the line that says /* That's all, stop editing! Happy publishing. */:
define('WP_SITEURL', 'https://example.com/m');
define('WP_HOME', 'https://example.com/m');
Alternatively, using const:
const WP_SITEURL = 'https://example.com/m';
const WP_HOME = WP_SITEURL;
Replace example.com with your domain and m with your subfolder name.
Step 3: Fix Permalink Issues (Pretty URLs)
If you are using pretty permalinks, create or update the .htaccess file inside the /m folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /m/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /m/index.php [L]
</IfModule>
Then go to WordPress Admin → Settings → Permalinks and click Save Changes to flush the rewrite rules.
Result
Your site will be fully accessible at:https://example.com/m
Option 2: Access WordPress from the Root URL (https://example.com) but Keep Files in Subfolder
This approach lets you keep WordPress files in a subfolder while serving the site from the root domain.
Step 1: Upload WordPress to a Subfolder
Upload all WordPress files into /public_html/m/ (or any subfolder).
Step 2: Set WP_SITEURL and WP_HOME
Add the following lines to wp-config.php:
define('WP_SITEURL', 'https://example.com/m');
define('WP_HOME', 'https://example.com');
Step 3: Copy and Edit the Index File
-
Copy these two files from the
/mfolder to the root/public_html/directory:-
index.php -
.htaccess
-
-
Edit the copied
index.phpand change:require( dirname( __FILE__ ) . '/wp-blog-header.php' );to:
require( dirname( __FILE__ ) . '/m/wp-blog-header.php' ); -
Update the
.htaccessfile in the root folder to handle permalinks:<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
Result
Users will visit the site at:https://example.com
Even though WordPress files reside in /public_html/m
Additional Notes and Troubleshooting
-
Do not change the WordPress Address or Site Address from the admin panel after configuring
wp-config.php, as it may overwrite your settings. -
Most plugins and themes will work properly unless they use hardcoded URLs.
-
If permalinks break after moving WordPress, re-save them from Settings → Permalinks.
-
Ensure SSL is properly set if your site uses HTTPS. Both
WP_SITEURLandWP_HOMEmust usehttps://.
Conclusion
Running WordPress from a subfolder can keep your root directory clean or serve multiple apps under one domain. Choose the configuration that fits your needs and follow the steps carefully.
If you're unsure which setup is best for your use case, contact support with your folder name and target site URL.
