簡體   English   中英

AWS服務器上的CodeIgniter htaccess問題

[英]CodeIgniter htaccess issue at AWS server

這是第一次使用CodeIngiter,而且我有網址訪問問題。 我必須在URL中包含index.php才能訪問頁面。

為了解決這個問題,我在這里參考 我遵循了所有步驟。

我已經在config.php更新為

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

根目錄下的.htaccess文件是

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

我無法將所有AllowOverride None更改為AllowOverride All。 在/etc/apache2/apache2.conf文件中。 如果這樣做,我什至無法訪問我的根URL。 我的/etc/apache2/apache2.conf文件如下。

# 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

我重新啟動了apache2服務器。

但是,如果沒有URL中的index.php,我仍然無法訪問。 還有什么問題?

使用以下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>

有類似問題的人請嘗試一下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM