我在这里看到了几个关于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
<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 这是我想要访问的网址。
任何指导将不胜感激!
修改 重写模块已经启用,虚拟主机映射正在运行,但我得到404。
答案 0 :(得分:0)
我是如何解决这个问题
显然我错过了
部分 <Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
在我的apache2.conf上。请务必从AllowOverride none
更改为AllowOverride all
。通过这样做,您可以告诉您的apache / var / www中文件夹内的.htaccess文件可以覆盖以前定义的规则,这对于CodeIgniter非常重要(如果您想从您的网址中删除index.php) )。
希望这有助于未来的人们。感谢那些为这个问题贡献时间的人。