htaccess codeigniter remove index.php



我在apache2.4中托管了带有php7.2 docker环境的codeigniter应用程序。无法正确解析路由。

路径

/var/www/html/apps/sample1

浏览器路径

http://localhost:8080/apps/sample1/

工作正常,但路由控制器和操作直到我使用index.php 才得到解决

http://localhost:8080/apps/sample1/index.php/admin/logn

正确预期

http://localhost:8080/apps/sample1/admin/logn

.htaccess当前配置,Apache mod_rewrite已启用

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/innovative_travel_web/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [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>  
<IfModule mod_php5.c>
php_value short_open_tag 1
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
</IfModule>

请指导我,我该怎么修。

1(创建类似的htaccess

RewriteEngine on
RewriteCond $1 !^(index.php|asset)
RewriteRule ^(.*)$ index.php?/$1 [L]
Options -Indexes

2( 在application/config/config.php文件中

$config['index_page'] = '';

在config.php 中设置

$config['index_page'] = '';

然后,根据你的根文件夹,你的.htaccess YouRewriteBase可能如下所示,如果应用程序在根文件夹中运行,则仅为/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder_name/
RewriteCond $1 !^(index.php|images|robots.txt)
#Removes access to the system folder by users.  
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#This snippet prevents user access to the application folder
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>
ErrorDocument 404 /index.php
</IfModule>

在config.php 中设置

$config['index_page'] = '';

in.hta

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /apps/sample1/index.php/$1 [L]
</IfModule>

你也需要指定目录,因为你的路径是/var/www/html/apps/sample1不是/var/www/html/

相关内容

  • 没有找到相关文章

最新更新