dongle0396 2016-11-26 06:37
浏览 60

AWS服务器上的CodeIgniter htaccess问题

This is the first time using CodeIngiter and I have url access issue. I have to include index.php in the url to access a page.

To solve the issue, I took a reference at here. I followed all steps.

I have updated at config.php as

$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

.htaccess file at root is

RewriteEngine On
RewriteCond $1 !^(index\.php | assets | images | js | css | uploads | favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

ubuntu@ip-172-31-28-229:/var/www/html/CodeIgniter$ a2enmod rewrite
Module rewrite already enabled

I can't change all AllowOverride None to AllowOverride All. in the /etc/apache2/apache2.conf file. If I do it, I even can't access my root url. My /etc/apache2/apache2.conf file is as follow.

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

I restarted my apache2 server.

But I still can't access without index.php in my url. What is still wrong?

  • 写回答

1条回答 默认 最新

  • dongtao4787 2016-11-26 08:28
    关注

    My problem was solved using the following mod_rewrite.c

    <IfModule mod_rewrite.c>
        RewriteEngine On
        Options +FollowSymlinks
    
        # - - - Use for 1and1 - - -
        # RewriteBase /
    
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    

    Somebody who has the similar issue, pls try this.

    评论

报告相同问题?

悬赏问题

  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗