apache2和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 noneAllowOverride all这样,您就是在告诉您的Apache,/ var / www内的文件夹中的.htaccess文件可以覆盖以前定义的规则,这对于CodeIgniter极为重要(以防您要从URL中删除index.php)。

希望这对以后的人们有所帮助。感谢那些为解决这个问题做出贡献的人。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Apache2和HeartBleed SSL问题

来自分类Dev

uwsgi和apache2问题

来自分类Dev

部署烧瓶和apache2 mod_wsgi的问题

来自分类Dev

Apache2权限问题

来自分类Dev

HTTP / 2和Apache2

来自分类Dev

Wildfly集群和Apache2

来自分类Dev

旧版Perl代码和Apache2

来自分类Dev

Apache2和mysql授权

来自分类Dev

旧版Perl代码和Apache2

来自分类Dev

如何安装和启动apache2

来自分类Dev

Apache2和域控制

来自分类Dev

Zabbix和apache2 conf

来自分类Dev

在Linux Apache2上找不到CodeIgniter URL文件

来自分类Dev

Ubuntu 14.04 Server:phpMyAdmin的Apache2问题

来自分类Dev

Apache2(CKAN)+ TOMCAT6 + Mod代理问题

来自分类Dev

在CentOS上为apache2编译乘客的问题

来自分类Dev

在Mac上使用apache2时出现权限问题

来自分类Dev

安装apache2时出现问题

来自分类Dev

Ubuntu 14.04 Server:phpMyAdmin的Apache2问题

来自分类Dev

在 ubuntu 18.04 上安装 Apache2 的问题

来自分类Dev

问题使用 Apache2 路由 React 页面

来自分类Dev

Mac上的/ private / etc / apache2和/ etc / apache2有什么区别

来自分类Dev

重新启动apache2和service apache2有什么区别?

来自分类Dev

apache2和couchdb在apache2上启用cors

来自分类Dev

当我的Linux机器上同时安装apache2服务器和apache tomcat服务器时出现的问题

来自分类Dev

Ubuntu 12.04 PHP 5.5和apache2 2.4

来自分类Dev

IPTable和端口重定向Apache2

来自分类Dev

Laravel和Apache2:禁止使用403

来自分类Dev

通过Tomcat7和Apache2访问Jenkins