我正在从7个小时开始挠头,但无法使我的CodeIgniter目录工作。不过,我对根域上的WordPress工作正常。问题是用CodeIgniter子文件夹。
下面是我的WordPress .htaccess for root域:(root域工作)
<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'] ='auto';
我不是在这里粘贴网站链接,以避免将我标记为垃圾邮件。如果有人需要查看,请在下面评论。
您可以尝试将其排除在重写中。
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/
我上面发布的文件非常好。问题仅仅是因为Codeigniter的控制器。如果任何控制器文件的第一个字母都有小字母,则不会打开,并且会给您 404 错误。尽管小帽子在 Godaddy 上效果很好,就像我这样做很长的那样。但是它们在 hostgator 托管上不起作用。
因此,请确保控制器中的每个文件必须从资本字母开始。谢谢!