在一个.htaccess文件很多的RewriteBase? [英] Many RewriteBase in one .htaccess file?

查看:679
本文介绍了在一个.htaccess文件很多的RewriteBase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个域名和一个单词$ P $同一台服务器上PSS-博客。现在我有一个问题(惊喜)。这个词preSS位于/ httpdocs资料/博客/域名指向/ httpdocs资料/而我想它重定向到/ httpdocs资料/域/。但是,obvisiously,我在Word preSS固定链接。

I have a domain and a wordpress-blog on same server. Now I have a problem (surprise). The wordpress is located on /httpdocs/blog/ and domain is pointing to /httpdocs/ and I'm trying to redirect it to /httpdocs/domain/. But, obvisiously, I have permalinks in Wordpress.

下面是我当前的.htaccess:

Here's my current .htaccess:

RewriteEngine On

RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

RewriteBase /
RewriteCond %{HTTP_HOST} domain.com
RewriteCond %{REQUEST_URI} !^/domain
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteRule ^(.*)$ domain/$1 [L]

但是,正如你已经propably认为,这是行不通的。字preSS'固定链接会影响到/域/还,所以我的图片和其他的URL出错。

But as you already propably assumed, this doesn't work. Wordpress' permalinks affects to /domain/ also, so my images and other urls go wrong.

有什么建议?是否有可能使用的RewriteBase这样吗?

Any advice? Is it possible to use RewriteBase like this?

推荐答案

没有,你只能有一个基本的URL。只需重写规则:

No, you can only have one base URL. Just rewrite your rules:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/. /blog/index.php [L]

RewriteCond %{HTTP_HOST} =example.com
RewriteCond %{REQUEST_URI} !^/domain
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteRule ^(.*)$ domain/$1 [L]

这篇关于在一个.htaccess文件很多的RewriteBase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆