【问题标题】:How to remove index.php from CodeIgniter3 install in subdirectory with Wordpress on root?如何从 CodeIgniter3 中删除 index.php 安装在根目录下的 Wordpress 子目录中?
【发布时间】:2015-08-05 06:10:25
【问题描述】:

所以这个问题的标题有点难以想出。这是交易,CI3 安装是这样的: www.mydomain.com.au/apps/TGPS 其中 TGPS 是 CI 应用程序。此外,在 web 文件夹的根目录上还有一个 Wordpress 安装程序。我的问题是,我需要从以下位置压缩 URL 的 .htaccess 设置是什么: www.domain.com/apps/TGPS/index.php/controller/function 对此: www.domain.com/apps/TGPS/controller/function

目前我有这个:

顶层.htacess是这样的:

# BEGIN WordPress
RewriteRule ^/apps($|/) - [L] 
# END WordPress

TGPS 中的 .htaccess 是这样的:

<IfModule mod_rewrite.c>
    RewriteEngine On

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #This last condition enables access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

应用程序中的 .htaccess 是标准的。

似乎我尝试的一切都破坏了 Wordpress、CodeIgniter 或无效。任何帮助将不胜感激。

【问题讨论】:

  • 请确保在您的 /etc/httpd/conf/httpd.conf 中或请搜索您的 httpd.conf 文件在哪里并将 AllowOverride None 更改为 AllowOverride All
  • 我做了更改,谢谢。
  • 抱歉,我做了更改,但实际上并没有改变任何东西。我只是假设这是过程的一部分。
  • RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] 现在试试这个
  • 复制上面的整个代码到你的.htaccess

标签: wordpress .htaccess codeigniter codeigniter-3


【解决方案1】:

乍一看,您缺少一个重写基础:

RewriteBase /apps/TGPS/

【讨论】:

    【解决方案2】:

    试试下面的代码

        RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
    RewriteRule ^index\.php$ / [L,R=301]
    

    然后是www到非www:

    RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
    

    【讨论】:

    • 那个.htaccess在目录中处于什么级别?
    • 写在&lt;IfModule mod_rewrite.c&gt;RewriteEngine On之后在htaccess公共目录中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    • 2011-01-31
    • 2018-02-05
    • 2021-09-10
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    相关资源
    最近更新 更多