Change Document Root for Wordpress: Difference between revisions
No edit summary |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
For the simplest way to give WordPress its own directory while having it show up as the root of your domain please do the following: | |||
Log into your Wordpress Admin. | Log into your Wordpress Admin. | ||
Line 11: | Line 11: | ||
'''Option 1:''' | '''Option 1:''' | ||
To change your document root, please | To change your document root, please click [https://wiki.bravenet.com/Change_Document_Root here] article which covers the steps required to update your websites root directory. | ||
'''Option 2:''' | '''Option 2:''' | ||
Line 27: | Line 26: | ||
RewriteRule ^(/)?$ /wordpress/index.php [L] | RewriteRule ^(/)?$ /wordpress/index.php [L] | ||
</IfModule> | </IfModule> | ||
# END WordPress redirect | # END WordPress redirect | ||
</pre> | </pre> | ||
'''Alternative option, which follows mostly the same steps is to do the following:''' | |||
# Go to the General panel. | # Go to the General panel. | ||
Line 38: | Line 37: | ||
# Edit your root directory's index.php. | # Edit your root directory's index.php. | ||
## Open your root directory's index.php file in a text editor | ## Open your root directory's index.php file in a text editor | ||
## Change the line that says: | ## Change the line that says: <code>require( dirname( __FILE__ ) . '/wp-blog-header.php' ); </code> | ||
<code>require( dirname( __FILE__ ) . '/wp-blog-header.php' ); </code> | ##: to the following: <code>require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );</code> | ||
to the following | |||
## Save the file. | ## Save the file. | ||
# Login to your site (if you aren't still already). The URL should still be ''http://example.com/wordpress/wp-admin/'' | # Login to your site (if you aren't still already). The URL should still be ''http://example.com/wordpress/wp-admin/'' | ||
# If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.) | # If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.) | ||
[[Category:Account Manager]] | |||
[[Category:Getting Started]] | |||
[[Category:Websites]] | |||
[[Category:WordPress]] |
Latest revision as of 14:35, 22 April 2022
For the simplest way to give WordPress its own directory while having it show up as the root of your domain please do the following:
Log into your Wordpress Admin.
- Go to the General panel.
- In the box for Site address (URL): change the address to the root directory's URL. Example: http://example.com
- Do the same as step 2 for home url
Next, you will want to either update the document root for your website or add an .htaccess file to the root of your website with the following RewriteRules:
Option 1:
To change your document root, please click here article which covers the steps required to update your websites root directory.
Option 2:
/web/domain.com/.htaccess
# BEGIN WordPress redirect <IfModule mod_rewrite.c> RewriteEngine On RewriteRule %{REQUEST_URI} !^/wordpress/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /wordpress/$1 RewriteRule ^(/)?$ /wordpress/index.php [L] </IfModule> # END WordPress redirect
Alternative option, which follows mostly the same steps is to do the following:
- Go to the General panel.
- In the box for Site address (URL): change the address to the root directory's URL. Example: http://example.com
- Click Save Changes. (Do not worry about the error message and do not try to see your blog at this point! You will probably get a message about file not found.)
- Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress (wordpress in our example) directory into the root directory of your site; the latter is probably named something like www or public_html. The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are not using pretty permalinks, then you may not have a .htaccess file. If you are running WordPress on a Windows (IIS) server and are using pretty permalinks, you'll have a web.config rather than a .htaccess file in your WordPress directory.
- Edit your root directory's index.php.
- Open your root directory's index.php file in a text editor
- Change the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
- to the following:
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
- to the following:
- Save the file.
- Login to your site (if you aren't still already). The URL should still be http://example.com/wordpress/wp-admin/
- If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)