简体   繁体   English

根域上的WordPress网站在子文件夹中无法正常工作

[英]WordPress site on root domain works BUT codeigniter in subfolder not working

I am scratching my head from 7 hours but unable to get my codeIgniter directory working. 我从7个小时开始就挠头了,但是无法使我的codeIgniter目录正常工作。 Though, my wordpress on root domain is working fine. 虽然,我在根域上的wordpress工作正常。 The problem is with codeigniter sub folder. 问题在于codeigniter子文件夹。

Below is my Wordpress .htaccess for root domain: (Root domain Working) 以下是我对根域的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>

Below is my subfolder for CodeIgniter .htaccess: (Not Working 404 ) 以下是我的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>

Everything is clean and clear. 一切都干净整洁。 What should be the problem above? 上面的问题应该是什么? I also tried to add web.config file and thought that would work but left with no success. 我还尝试添加web.config文件,并认为可以运行,但没有成功。 Below is 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>

To make it more explained. 为了使其更加解释。 Below is my uri_protocol property: 以下是我的uri_protocol属性:

$config['uri_protocol'] = 'AUTO'; $ config ['uri_protocol'] ='AUTO';

I am not pasting the site link here to avoid people marking me as spam. 我不会在此处粘贴网站链接,以避免有人将我标记为垃圾邮件。 If anyone need to see please comment below. 如果有人需要查看,请在下面发表评论。

You can try this to exclude your dir from rewrite. 您可以尝试这样做,以免您的目录被重写。

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

Replace thedir with your directory name. thedir替换为您的目录名称。

your wordpress .htaccess should be like the following: 您的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

After that you should be able to access your directory with 之后,您应该可以使用

http://yourdomanin.com/chat/

The files I posted above in the question are perfectly well. 我上面在问题中发布的文件非常好。 The issue was only because of the controllers of codeigniter. 问题仅是由于codeigniter的控制器。 If the first letter of any file of controller have small letter then it is not going to be open and will give you 404 error. 如果控制器的任何文件的首字母都有小写字母,则它将不会打开,并且会给您404错误。 Though small caps works well on Godaddy as I have been doing this very long. 虽然小盘在Godaddy上效果很好,因为我已经做了很长时间了。 But they don't work on HostGator Hosting. 但是它们不适用于HostGator托管。

So, Make sure that your each file in controller must start with a capital alphabet. 因此,请确保控制器中的每个文件都必须以大写字母开头。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM