的.htaccess映射WWW和放大器;非www到文件夹和维护WWW [英] .htaccess mapping www & non-www to folder and maintain www
问题描述
我没有的.htaccess
专家和极其很少使用它。我通过网络几种解决方案和SO但没有运气还是去了。所以,我有一个IP称 1.2.3.4
有我的话preSS应用程序的子文件ABC说,在的/ var / www / html等/
。 DNS已经设置,使 www.mydomain.com
和 mydomain.com
指向IP 1.2.3.4
。
I am no .htaccess
expert and extremely rarely use it. I went through several solutions on Net and SO but no luck still. So I have one IP says 1.2.3.4
that has sub folder of my wordpress application says ABC in the /var/www/html/
. DNS has been setup so that www.mydomain.com
and mydomain.com
point to IP 1.2.3.4
.
我有我的的.htaccess
内容如下文件,它仅支持 mydomain.com
。如预期的那样显示,除了当我把内容 www.mydomain.com
它显示Linux的主页。
I have my content in .htaccess
file as below and it only supports mydomain.com
. The content is displayed as expected except when I put www.mydomain.com
it displays Linux home page.
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteCond %{REQUEST_URI} !^/ABC/
RewriteRule (.*) /ABC/$1
当我把 www.mydomain.com
浏览器自动更改URL为 mydomain.com
。
When I put www.mydomain.com
the browser automatically change the URL to mydomain.com
.
除此之外,我也想有 WWW
所有域。从 mydomain.com
办法要求将显示为 www.mydomain.com
。后来,我将只是把 www.mydomain.com
我的道preSS的URL配置。有些帮助ARE AP preciated。
Apart from that, I would also like to have all domain with www
. Means request from mydomain.com
will be displayed as www.mydomain.com
. Later I will just put www.mydomain.com
in the URL config of my wordpress. Some helps are appreciated.
推荐答案
切换回旧的.htaccess code。我收到了你最后一次更新后,更加明确。你有字preSS文件的public_html / ABC,但需要你的网站的网址为www.example.com。让我来解释一步一步来。
Switch back to your old .htaccess code. I got it more clear after your last update. You have wordpress files in "public_html/ABC" but need your website url as www.example.com. Let me explain step by step.
- 在粘贴的.htaccess旧code。
- 副本(不移动)从/ ABC文件夹中的index.php和.htaccess文件到您的网站的public_html。
- 查找的public_html / index.php文件作为一个规则规定(目录名(文件)/wp-blog-header.php');而代之以规定(目录名(文件)/ABC/wp-blog-header.php'); (不要在文件夹中编辑index.php文件/ ABC !!)
- 仅更改网站地址(URL),在常规设置(设置 - >常规)为的http:// www.example.com 。
- Paste your old code in .htaccess.
- copy (do not move) the index.php and .htaccess file from the /ABC folder to the "public_html" of your site.
- Find one rule in "public_html/index.php" as "require( dirname( FILE ) . '/wp-blog-header.php' );" and replace it with "require( dirname( FILE ) . '/ABC/wp-blog-header.php' );" (do not edit the index.php file in the folder /ABC!!)
- change ONLY the "Site Address (URL)" in the general settings (Settings -> General) to "http://www.example.com".
这篇关于的.htaccess映射WWW和放大器;非www到文件夹和维护WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!