[英]CodeIgniter htaccess issue at AWS server
This is the first time using CodeIngiter and I have url access issue. 这是第一次使用CodeIngiter,而且我有网址访问问题。 I have to include index.php in the url to access a page.
我必须在URL中包含index.php才能访问页面。
To solve the issue, I took a reference at here . 为了解决这个问题,我在这里参考了 。 I followed all steps.
我遵循了所有步骤。
I have updated at config.php as 我已经在config.php更新为
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
.htaccess
file at root is 根目录下的
.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
I can't change all AllowOverride None to AllowOverride All. 我无法将所有AllowOverride None更改为AllowOverride All。 in the /etc/apache2/apache2.conf file.
在/etc/apache2/apache2.conf文件中。 If I do it, I even can't access my root url.
如果这样做,我什至无法访问我的根URL。 My /etc/apache2/apache2.conf file is as follow.
我的/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
I restarted my apache2 server. 我重新启动了apache2服务器。
But I still can't access without index.php in my url. 但是,如果没有URL中的index.php,我仍然无法访问。 What is still wrong?
还有什么问题?
My problem was solved using the following mod_rewrite.c 使用以下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. 有类似问题的人请尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.