我知道这个问题已被多次询问,但已经尝试了所有解决方案但是仍然可以使用
我的配置文件如下
$config['base_url'] = 'http://immodernafrican.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess文件是
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|googlexxxxxxxx\.html|mobile.html)
RewriteRule ^(.*)$ index.php/$1 [L]
更改
AllowOverride None
要
AllowOverride All
但我的网址仍然适用于index.php
immodernafrican.com/index.php/AncientHistory
除此之外,它给出了404错误
immodernafrican.com/AncientHistory
答案 0 :(得分:0)
只需将.htaccess
更改为此
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
答案 1 :(得分:0)
你的.htaccess文件将是
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
配置文件
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
答案 2 :(得分:0)
关注此
对于服务器
激活mode_rewrite模块
sudo a2enmod rewrite
重启apache
sudo service apache2 restart
编辑000-default.conf
sudo nano /etc/apache2/sites-available/000-default.conf
搜索“DocumentRoot / var / www / html”并在下方添加以下行:
<Directory "/var/www/html">
AllowOverride All
</Directory>
通过CTRL-X,“y”和ENTER保存并退出nano编辑器。
重启服务器:
sudo service apache2 restart
在config.php中
$config['base_url'] = 'http://immodernafrican.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
在routes.php中
$route['default_controller'] = "YOUR_DEFAULT_CONTROLLER";
htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>