>我正在Kali Linux中研究代码点火器,我已经按照文档中提到的配置了.htaccess文件并正确配置文件,但是没有索引就无法正常工作.php
a2enmod rewrite
我还启用了重写模式并重新启动了 apache。这是我的.htaccess文件
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
in config.php
$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';
在项目的位置使用以下内容创建 .htaccess 文件 (例如:/var/www/html/yourproject 在"yourproject"文件夹中创建 .htaccess (
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
将以下内容添加到虚拟主机配置文件中
<Directory "/var/www/html/yourproject">
Options All
AllowOverride All
Allow from all
</Directorey>
然后重新启动 Apache
按照以下步骤从网址中删除index.php
1(从配置文件中删除"索引.php.php">
$config['index_page'] = "";
2( 您的 .htaccess 文件应为:
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
3(在某些情况下,您还必须在配置文件中更改此设置
//find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"
只需在您的 .htaccess 文件中使用它
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>