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

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

问题描述

我在同一台服务器上有一个域和一个 wordpress 博客.现在我有一个问题(惊喜).wordpress 位于/httpdocs/blog/上,域指向/httpdocs/,我试图将其重定向到/httpdocs/domain/.但是,很明显,我在 Wordpress 中有永久链接.

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]

但是正如您已经假设的那样,这行不通.Wordpress 的永久链接也会影响/domain/,所以我的图片和其他网址出错了.

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]

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

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