2012-10-17 136 views
2

我遇到了客户网站的问题。我为他创建了一个新的WordPress网站,现在我遇到了htaccess重定向的问题。htaccess重定向问题,Wordpress和静态html网站没有正确重定向

之前,我在服务器上安装的WordPress,有两个静态基本的HTML站点。一个在使用主域的public_html根目录中,一个子文件夹中的完全不同的子网站使用htaccess重写规则将子域指向该文件夹。

现在有Wordpress搞乱了重定向。 Wordpress当然对原始的htaccess文件进行了修改。除此之外,客户还必须更换主机提供商内的服务器以获得更新的PHP版本,所以我必须从头开始编写htaccess文件。

这是当前htaccess的文件:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /www/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /www/index.php [L] 
</IfModule> 

# END WordPress 

RewriteEngine On 
Options +FollowSymlinks 
RewriteBase/
RewriteCond %{HTTP_HOST} ^(www.)?subdomainurl.com$ [NC] 
RewriteCond %{REQUEST_URI} !^/subdomainfolder/ 
RewriteRule ^(.*)$ subdomainfolder/$1 [L] 

的WordPress安装在一个文件夹名为www和URL被改写,它精美的作品。但是我遇到了子域问题。在上面的代码中,我用subdomainurl.com替换了子域url,该站点位于public_html/subdomainfolder /中。

现在,当我输入www.subdomainurl.com,重定向的作品,显示该网站。但www.subdomainurl.index.html键入不。它必须写成www.subdomainurl.com/subdomainfolder/index.html,所以我显然不写重定向权,也添加了子域文件夹。我试图与htaccess混合使用,但无法做到。每当我尝试改变主题的Wordpress网站中的404时,

目前这些工作: www.maindomain.com/subdomainfolder/index.html www.subdomainurl.com/subdomainfolder/index.html

而且这不,我正在努力做: www.subdomainurl.com/index.html

我不是一个重定向专家,任何帮助将不胜感激。

编辑/附加组件:

下面是从重定向子域的子文件夹,并改写了URL旧服务器的旧代码,它没有了,所以我抛弃它。

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www.)?subdomainurl.com$ [NC] 
RewriteCond %{REQUEST_URI} !^/subdomainfolder/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /subdomainfolder/$1 
RewriteCond %{HTTP_HOST} ^(www.)?subdomainurl.com$ [NC] 
RewriteRule ^(/)?$ subdomainfolder/index.html [L] 
+0

简而言之,我只需要从此htaccess文件中的最终url中删除文件夹名称。 从 www.subdomainurl.com/subdomainfolder/index.html 至 www.subdomainurl.com/index。html – tvuollo

回答

0

我没有在htaccess文件中看到只有子域和主域的条目。

+0

你是什么意思? 目前有两个域指向同一个虚拟主机空间。第二个是在.htaccess中提到的,主要的不是,因为它们都是由提供者默认定向到网络空间根目录的,并且文件夹重定向必须由.htaccess完成。 – tvuollo

0

目前我使用这个代码

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /www/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /www/index.php [L] 
</IfModule> 

END WordPress 

RewriteEngine On 
Options +FollowSymlinks 
RewriteBase/
RewriteCond %{HTTP_HOST} ^(www.)?subdomainurl.com$ [NC] 
RewriteCond %{REQUEST_URI} !subdomainfolder 
RewriteRule ^(.*)$ subdomainfolder$1 

这会将整个二级域名(subdomainurl.com)作为www.subdomainurl.com/subdomainfolder和它的作品一样,(www.subdomainurl.com/subdomainfolder /index.html,www.subdomainurl.com/subdomainfolder/work.html等),但它仍然不是客户真正想要的。我仍然需要通过htaccess从网址中删除子域文件夹部分,到目前为止我还没有成功。我想我没有把它放在代码的最后一行。