从根目录下的Wordpress的子文件夹的Codeigniter URL中删除index.php [英] Remove index.php from Codeigniter URL in subfolder with Wordpress in root

查看:73
本文介绍了从根目录下的Wordpress的子文件夹的Codeigniter URL中删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器子文件夹中的Codeigniter应用程序以及文档根目录中的Wordpress安装遇到一些问题。如果我使用 .htaccess

I'm having some issues with a Codeigniter app in a subfolder on my server along with a Wordpress install in the document root. If I hide the index.php of the Codeigniter URL with .htaccess

/codeigniter/.htaccess

DirectoryIndex index.php

<IfModule mod_rewrite.c>

  RewriteEngine on
  RewriteBase /
  RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]

</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 index.php
</IfModule> 

并让Wordpress忽略 / codeigniter RewriteCond%{REQUEST_URI}!^ /(codeigniter)。* $

And get Wordpress to ignore /codeigniter with RewriteCond %{REQUEST_URI} !^/(codeigniter).*$

/。htaccess

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

然后导航到 www.mysite.com/codeigniter/my_controller/my_function ,出现404错误未指定输入文件。我发现此处,即在 RewriteRule ^(。*)$索引之后添加 .php 解决了Codeiginiter 404错误。

Then navigate to www.mysite.com/codeigniter/my_controller/my_function, I get a 404 error No input file specified. I found here, that adding a ? after RewriteRule ^(.*)$ index.php solves the Codeiginiter 404 error.

/codeigniter/.htaccess

RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

但是我现在遇到Wordpress 404错误,所以看来如果我将 index.php 替换为<$ c /codeigniter/.htaccess 中的$ c> index.php?, /。htaccess中的Wordpress重写规则 code>, RewriteCond%{REQUEST_URI}!^ /(codeigniter)。* $ 被忽略。

However I'm now getting a Wordpress 404 error, so it seems if I replace index.php with index.php? in /codeigniter/.htaccess, the Wordpress rewrite rule in /.htaccess, RewriteCond %{REQUEST_URI} !^/(codeigniter).*$ gets ignored. Is there a better way to handle this?

预先感谢!

推荐答案

codeigniter目录中的 RewriteBase 应该说 / codeigniter /

The RewriteBase in the codeigniter directory should say /codeigniter/

RewriteBase /codeigniter

否则重写为 index.php 最终进入了wordpress路由器。

Otherwise the rewrite to index.php ends up going to wordpress' router.

这篇关于从根目录下的Wordpress的子文件夹的Codeigniter URL中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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