根域上的WordPress站点工作但子文件夹中的codeigniter不起作用

问题描述 投票:0回答:2

我从7个小时开始摸不着头脑,但无法让我的codeIgniter目录工作。虽然,我在root域上的wordpress工作正常。问题在于codeigniter子文件夹。

下面是我的Wordpress .htaccess根域:(根域工作)

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
   ErrorDocument 404 /index.php
</IfModule>

下面是我对CodeIgniter .htaccess的子文件夹:(不工作404)

<IfModule mod_rewrite.c> 
RewriteEngine On
RewriteBase /chat/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /chat/index.php/$1 [L] 
</IfModule>

一切都干净清晰。上面应该是什么问题?我还试图添加web.config文件,并认为这可行,但没有成功。下面是web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Clean URL" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
         <staticContent>
                  <mimeMap fileExtension=".json" mimeType="manifest/json" />
         </staticContent>
    </system.webServer>
</configuration>

为了使它更加解释。以下是我的uri_protocol属性:

$ config ['uri_protocol'] ='自动';

我没有粘贴网站链接,以避免人们将我标记为垃圾邮件。如果有人需要看,请在下面评论。

wordpress apache .htaccess codeigniter web-config
2个回答
0
投票

您可以尝试这样做以排除您的目录重写。

RewriteCond %{REQUEST_URI} !^/(thedir|thedir/.*)$

thedir替换为您的目录名称。

你的wordpress .htaccess应该如下:

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

之后,您应该能够访问您的目录

http://yourdomanin.com/chat/

0
投票

我在问题上面发布的文件非常好。问题只是因为codeigniter的控制器。如果任何控制器文件的第一个字母都有小写字母,那么它将不会打开并且会给你404错误。虽然小帽子对Godaddy很有效,但我已经这么做了很长时间。但它们不适用于HostGator Hosting。

因此,请确保控制器中的每个文件都必须以大写字母开头。谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.