简体   繁体   中英

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. Though, my wordpress on root domain is working fine. The problem is with codeigniter sub folder.

Below is my Wordpress .htaccess for root domain: (Root domain Working)

<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 )

<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. Below is 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:

$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.

your wordpress .htaccess should be like the following:

# 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. 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. Though small caps works well on Godaddy as I have been doing this very long. But they don't work on HostGator Hosting.

So, Make sure that your each file in controller must start with a capital alphabet. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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