[英]Issues with apache2 and CodeIgniter
我在這里看到了關於apache和CodeIgniter的幾個問題,但似乎沒有一個適合我。
有什么問題?
顯然,apache不讀取.htaccess文件。
我做了什么測試?
好吧,我創建了一個.htaccess文件,其內容如下:
AddHandler php5-script .php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|shared|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
為了測試它是否正在執行,我已經切換了
RewriteRule .* http://stackoverflow.com/ [L,R]
只是為了檢查它是否正在執行。 沒有這種運氣。
我的虛擬主機
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/videosonline"
ServerName videosonline.local
<directory "/var/www/videosonline">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|shared|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
</directory>
</VirtualHost>
我試過直接在其上包含.htaccess條目,但也沒有。
CodeIgniter config.php
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = '';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';
我還更改了主機文件,使其包含127.0.0.1 videosonline.local,這是我想要訪問的URL。
任何指導將不勝感激!
編輯重寫模塊已啟用,並且虛擬主機映射正在運行,但是我收到404。
我如何解決這個問題
顯然我錯過了本節
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride all Require all granted </Directory>
在我的apache2.conf中。 確保將“ AllowOverride none
更改為“ AllowOverride all
。 這樣,您就是在告訴您的Apache,/ var / www內的文件夾中的.htaccess文件可以覆蓋以前定義的規則,這對於CodeIgniter極為重要(以防您要從URL中刪除index.php)。
希望這對以后的人們有所幫助。 感謝那些為解決這個問題做出貢獻的人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.