【发布时间】:2022-01-28 00:40:07
【问题描述】:
我刚刚安装了 codeigniter,所以如果我输入:
http://mysuperwebpage.comyr.com/projects/thebookshelf/index.php/welcome
它会按应有的方式显示所有内容。
但是我想去掉url中的这个index.php,这样你就可以访问欢迎控制器,而无需在/welcome之前输入index.php:
http://mysuperwebpage.comyr.com/projects/thebookshelf/welcome
所以我按照我在堆栈上的相同问题中找到的所有必要步骤进行操作。我试过的:
config.php:
$config['base_url'] = 'http://mysuperwebpage.comyr.com/projects/thebookshelf/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess 位于根文件夹中的文件:http://mysuperwebpage.comyr.com/projects/thebookshelf/.htaccess
尝试 #1(不起作用)
.htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
尝试 #2(不起作用)
.htaccess:
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
尝试 #3(不起作用)
.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我错过了什么或做错了什么?第一次使用.htaccess。
【问题讨论】:
标签: .htaccess codeigniter