3 回答
TA贡献1831条经验 获得超9个赞
您的服务器中似乎未启用 mod_rewrite。如果重写规则不起作用,请确保您在 Apache 配置文件中允许 .htaccess 文件。目录部分应包含 AllowOverride All 选项:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
不要忘记对 Apache 配置文件的任何更改都需要重新启动服务!
TA贡献1825条经验 获得超4个赞
尝试以下解决方案:
转到 application\config\config.php 文件
做出改变
$config['index_page'] = 'index.php';
至
$config['index_page'] = '';
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /YourCIFolderName/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /YourCIFolderName/index.php [L]
</IfModule>
TA贡献1884条经验 获得超4个赞
步骤1
去 application/config/config.php 找到
$config['index_page'] = 'index.php';
change it to
$config['index_page'] = '';
第2步
转到 application/config/routes.php
评论结束后从页面底部删除所有内容并粘贴以下代码
$route['default_controller'] = 'main'; // main is your default controller name
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['(:any)'] = "main/$1";
$route['admin'] = 'admin/login';
第 3 步
在根文件夹中添加一个名为 .htaccess 的新文件,其中包含名为 application 和 system 等的文件夹
添加以下代码并打开网站
RewriteEngine On
RewriteBase /
Options All -Indexes
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^ - [L]
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# remove index.php
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,NE,L]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Header set Access-Control-Allow-Origin "*"
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
- 3 回答
- 0 关注
- 213 浏览
添加回答
举报