CodeIgniter使用.htaccess文件删除index.php
使用.htaccess文件删除CodeIgniter中的index.php对我不起作用。我尝试了以下代码,尽管不起作用CodeIgniter使用.htaccess文件删除index.php,php,codeigniter,Php,Codeigniter,使用.htaccess文件删除CodeIgniter中的index.php对我不起作用。我尝试了以下代码,尽管不起作用 <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
</IfModule>
重新启动发动机
重写基/
1美元^(索引\.php | resources | robots\.txt)
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/index.php?/$1[L,QSA]
我试过这个。但不起作用。但它在我的本地主机上起作用。我还编辑了httpd.config文件,但没有使用。
请帮帮我。试试这个代码
<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,
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
步骤1 打开文件夹
“application/config”
并打开文件“config.php”。
在config.php文件中查找并替换以下代码。
找到下面的代码
步骤2
在.htaccess文件中编写以下代码
你提到的代码是正确的 您必须修改apache2.conf(/etc/apache2/apache2.conf---它的“我的服务器”路径)检查您的路径 找到这个罪犯
“AllowOverride None”
和/var/www/
或/var/www/html
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
选项索引跟随符号链接
不允许超限
要求所有授权
更新至
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
选项索引跟随符号链接
允许超越所有
要求所有授权
不要忘记重新启动sudo服务apache2,如果使用localhost或domainname.com,请尝试在config.php中更改基本url
$config['base_url'] = 'http://localhost/'; // localhost
或
加载项
.htacess
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$
从config.php
中的$config['index\u page']
中删除“index.php”(保留空白值)
和修复项目文件夹的权限。/var/www/也很重要。您工作目录的路径应该正确谢谢您的回复我得到了修复我已经尝试了上面的代码我得到了内部服务器错误谢谢您的回复我得到了修复发现这一点,可能是使用full有不同的htaccess供您尝试。谢谢I got解决方案在您学习阅读apache文件之前,谷歌将其命名为“far in space codeigniter htaccess”。这是您可能需要的最有用的示例,也是迄今为止我找到的最好的示例。感谢您的回复,我已将其修复
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
$config['base_url'] = 'http://localhost/'; // localhost
$config['base_url'] = 'http://domainname.com/'; // domainname.com
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$