我怎么可以重写特定的网址上现有的网站加载它安装在一个子目录从Word preSS网页? [英] How can I rewrite specific URLs on an existing site to load pages from WordPress which is installed in a subdirectory?

查看:134
本文介绍了我怎么可以重写特定的网址上现有的网站加载它安装在一个子目录从Word preSS网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在example.com建成codeIgniter现有站点。

I have an existing site built with CodeIgniter at example.com.

我有一个字preSS安装在example.com/wp。网址如下:example.com/wp/my-page

I have a WordPress install at example.com/wp. Urls look like this: example.com/wp/my-page

我试图找出如何我可以重写example.com/my-page显示example.com/wp/my-page的内容,但仍将显示URL作为example.com/my-page。

I'm trying to figure out how I can rewrite example.com/my-page to display the contents of the example.com/wp/my-page while still displaying the URL as example.com/my-page.

codeIgniter控制index.php文件,所以我不能使用Word preSS的index.php文件在根。​​

CodeIgniter controls the index.php file, so I can't use WordPress's index.php in the root.

我中途有,我有一个普通的HTML文件中工作,但得到涉及字preSS重写的URL / WP子目录。

I'm half way there, I have it working with a plain HTML file, but getting WordPress involved rewrites the url to the /wp subdirectory.

下面我所用,在example.com的根是:

Here's what I'm using, in the example.com root:

<IfModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks

RewriteBase /

RewriteRule ^my-page /wp/my-page [P]

</IfModule>

当我访问example.com/my-page我结束了在例如/ WP。

When I visit example.com/my-page I end up at example/wp.

我想这事做在/ WP /目录下,看起来像这样的标准的Word preSS的.htaccess:

I imagine it has something to do with the standard WordPress .htaccess in the /wp/ directory which looks like this:

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

我已经尝试添加[P]标记到Word preSS规则,但没有运气,我也试过不设置重写基地/ WP /.

I've tried adding the [P] flag to the WordPress rules but no luck, I also tried not setting the rewrite base to /wp/.

现在的问题是,我不明白这东西在足够的细节来找出我的问题,还是要知道这是否是可能的。

The problem is I don't understand this stuff in enough detail to figure out my issue, or to know whether this is possible.

总之,我觉得我试图重写URL重写不执行重定向(因此,[P]标志)。

In summary, I think I'm trying to rewrite a rewritten URL without doing a redirect (hence the [P] flags).

可以这样做?任何帮助将是AP preciated。

Can this be done? Any help would be appreciated.

推荐答案

$猫的.htaccess

RewriteEngine on
RewriteBase /
RewriteRule ^my-page wp/my-page [L]

$树-a WP

wp
|-- .htaccess
`-- index.php

$猫WP /的.​​htaccess

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

$猫WP / index.php文件

<pre><?php print_r($_SERVER); ?></pre>


结果:


Result:

URL在浏览器中可见: http://example.com/my-page 输出:

URL visible in browser: http://example.com/my-page Output:

Array
(
[REDIRECT_REDIRECT_STATUS] => 200
[REDIRECT_STATUS] => 200
[HTTP_HOST] => example.com
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_CONNECTION] => keep-alive
[PATH] => /usr/local/bin:/usr/bin:/bin
[SERVER_SIGNATURE] => Apache/2.2.16 (Debian) Server at example.com Port 80
[SERVER_SOFTWARE] => Apache/2.2.16 (Debian)
[SERVER_NAME] => example.com
[SERVER_ADDR] => 1.2.3.4
[SERVER_PORT] => 80
[REMOTE_ADDR] => 4.3.2.1
[DOCUMENT_ROOT] => /www/vhosts/example.com/
[SERVER_ADMIN] => webmaster@example.com
[SCRIPT_FILENAME] => /www/vhosts/example.com/wp/index.php
[REMOTE_PORT] => 57775
[REDIRECT_URL] => /wp/my-page
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] => 
[REQUEST_URI] => /my-page
[SCRIPT_NAME] => /wp/index.php
[PHP_SELF] => /wp/index.php
[REQUEST_TIME] => 1342091732
)


所以,如果你仍然看到了这一点后,重定向,正由字preSS 的PHP code完成

这篇关于我怎么可以重写特定的网址上现有的网站加载它安装在一个子目录从Word preSS网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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