[英]Codigniter htaccess error 404 at production
我非常了解服務器技術。我知道這個問題問了很多遍了,但是我真的沒有讓它運行。 它與
domain.com/2.0/index.php/test
但是當您刪除index.php時,它會拋出
在此服務器上找不到請求的URL /2.0/test。 domain.com端口443上的Apache / 2.2.15(CentOS)服務器
我的項目結構
-
的public_html
--2.0(這是我的項目文件夾,可以在其中放置ci。它具有sys,app,.htaccess)
- 的.htaccess
關於這個問題
我有兩個htaccess根源提到上面之一是在2.0文件夾內
而且奇怪的是,我在htaccess文件中寫的內容永遠不會影響任何內容
的public_html /的.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
的public_html / 2.0 / htaccess的
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
我的httpd.conf
<VirtualHost *:443>
ServerAdmin info@domain.com
DocumentRoot /home/natural/public_html
ServerName api01.domain.net
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/access_log common
SSLEngine on
SSLCertificateFile /home/natural/api01.domain.net.crt
SSLCertificateKeyFile /home/natural/api01.domoin.key
<Directory />
Options Indexes FollowSymLinks
Allow from all
AllowOverride None
</Directory>
</VirtualHost>
我搜索了很多,然后按照堆棧溢出的所有答案進行操作,但是沒有運氣。
httpd.conf中的指令“ AllowOverride None”將禁止對指定目錄(在本例中為/)中的.htaccess文件進行解析–您是否可以確認實際上已經對您的.htaccess文件進行了解析?
如果不是,請將httpd.conf文件中的Directory子節修改為:
<Directory />
Options Indexes FollowSymLinks
Allow from all
AllowOverride All
</Directory>
解決問題?
有關更多信息: http : //httpd.apache.org/docs/2.4/mod/core.html#allowoverride
我認為2.0是該網站的新版本。 看起來/2.0/.htaccess
是寫的,好像它應該在根文件夾中一樣。 嘗試在引擎RewriteBase /2.0/
后添加RewriteBase /2.0/
。 當您用2.0
替換根文件夾的內容時,可以稍后將其刪除。
主要問題是您的# Handle Front Controller...
規則。 它會捕獲所有虛擬URL,直到它們進入2.0
文件夾。 嘗試將其更改為此:
RewriteRule ^(?!2\.0(?:/|$)) index.php [L]
這將從當前站點的虛擬URL中排除2.0
文件夾。
您仍然需要另一個答案所建議的AllowOverride all
,並且目錄應與DocumentRoot
相同,而不是/
。
將此代碼添加到root->。htaccess文件中
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteRule ^(?!2\.0(?:/|$)) index.php [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.