我知道周围有很多解决方案,并尝试了一切。问题是,当我在codeigniter子文件夹中放置.htaccess
时,它不会被读取。我认为这是因为AllowOverride
指令,但我不能改变它。
我试图跳过不属于wordpress的主要子文件夹,我在根htaccess
中调用了#34; sandbox"(这是wordpress的一部分),所以它没有"继承"重写的任何问题(例如,在codeigniter项目中没有由wordpress管理的404)。
问题是,正如我所说,未读取/ sandbox / ciproject /文件夹中的.htaccess。所以,我在主要的.htaccess中尝试了这个,并且它工作了一段时间。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/?sandbox/
RewriteRule . /index.php [L]
RewriteBase /sandbox/ciproject/
RewriteCond $1 ^(application|system|private|logs)
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|img|fonts)
RewriteRule ^(.*)$ - [PT,L]
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
这让我可以让它工作一段时间......但它不再起作用了。还有什么我可以尝试的吗?我已经改变了codeigniter项目的配置,所以它没有使用index.php,但没有。我现在只得到一个服务器错误500,如果我删除了htaccess的后半部分,我只得到404作为一个回复来摆脱index.php
我不知道我是否丢失了一些数据,但只是询问并且我会对此进行编辑,因此您不会对此视而不见。
答案 0 :(得分:1)
根据我的理解,你的代码点火器部分不起作用,因为你的htaccess中有两个冲突的重写规则。
RewriteRule ^(.*)$ - [PT,L]
RewriteRule ^(.*)$ index.php/$1 [PT,L]
这是一个冲突的规则集。删除其中一行然后尝试。它应该工作。
答案 1 :(得分:1)
Use only this code in htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sandbox/ciproject/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]