Wordpress从根目录移动到一个子目录(Moving a Root install to its own directory)
The process to move WordPress into its own directory is as follows:
- Create the new location for the core WordPress files to be stored (we will use /wordpress in our examples). (On linux, use mkdir wordpress from your www directory. You'll probably want to use "chown apache:apache" on the wordpress directory you created.)
- Go to the General panel.
- In the box for WordPress address (URL): change the address to the new location of your main WordPress core files. Example: http://example.com/wordpress
- 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.)
- Move your WordPress core files to the new location (WordPress address).
- Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address). 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. As stated above, copy (don't move) the index.php file to your root directory, but MOVE (DON'T COPY) the web.config file to your root directory.
- Open your root directory's index.php file in a text editor
- Change the following and save the file. Change the line that says:
require('./wp-blog-header.php');
to the following, using your directory name for the WordPress core files:
require('./wordpress/wp-blog-header.php'); - Login to the new location. It might now 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.)
Wordpress从一个子目录移动到根目录(Using a pre-existing subdirectory instal)
If you already have WordPress installed in its own folder (i.e. http://example.com/wordpress) then the steps are as follows:
- 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 directory into the root directory of your site (Blog address). 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. As stated above, copy (don't move) the index.php file to your root directory, but MOVE (DON'T COPY) the web.config file to your root directory.
- Open your root directory's index.php file in a text editor
- Change the following and save the file. Change the line that says:
require('./wp-blog-header.php');
to the following, using your directory name for the WordPress core files:
require('./wordpress/wp-blog-header.php'); - Login to your site. It 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.)
将网站根目录重定向到一个子目录中的wordpress(Pointing your home site's URL to a subdirectory)
In some cases, you may have a WordPress site that changes significantly every year, such as with a conference website. If you want to install each year's version of the site in a subdirectory, such as /2010, /2011, and /2012, but have the root domain (yoursite.com) automatically redirect to a particular subdirectory (usually the latest), follow this technique:
- Install WordPress in a subdirectory, such as /2012.
- In your root folder (not the subdirectory folder), download and open your .htaccess file.
- Add the following to your .htaccess file:
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$ RewriteRule ^(/)?$ blog [L]
- In the above code, change the "YourDomain.com" value to your root domain.
- In the above code, change the "blog" value to the subdirectory.
- Save and upload the .htacess file back to your root directory.
Now when users to go your root domain (yoursite.com), it will
automatically redirect to the subdirectory you specified. When you want
to redirect to a new subdirectory, such as the conference site for next
year, just update the .htaccess redirect code.
文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面