删除CodeIgniter中的index.php在Laragon中不起作用

new9mtju  于 2022-12-07  发布在  PHP
关注(0)|答案(2)|浏览(92)

我要在使用Laragon时从CodeIgniter中的URL移除index.php
我已经在CodeIgniter中编辑了.htaccess文件并应用了一个规则;我还将application/config/config.php中的index_page变量更改为空字符串。
正如预期的那样,它在使用WampServer/xampserver设置的Web环境中工作得非常好,但在使用Laragon时失败。
问题可能与Laragon环境有关,但我不知道如何解决它。
我怎样才能让它在Laragon environment中工作?(就像在Wampserver中工作一样)。
我的.htaccess文件包含以下代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /myFolder/index.php/$1 [L]
olmpazwi

olmpazwi1#

C:\laragon\etc\apache2\sites-enabled中,您将在工作目录中找到laragon的所有v-host。
当你找到一个代码点火器,你打开编辑它,你会看到一个正常的apache VirtualHost
更改此行:<Directory "C:/workspace/my_project">
至:<Directory "C:/workspace/my_project/index.html">
重命名laragon .conf文件并从文件名中删除auto.
重新启动所有程序。

  • 小心打开正确的虚拟主机。Laragon创建2个虚拟主机,一个使用设置中定义的扩展名,另一个使用.com扩展名。*

编辑:

<VirtualHost *:80> 
    DocumentRoot "C:/laragon/www/gmap_polygons/application/""
    ServerName gmap_polygons.dev 
    ServerAlias *.gmap_polygons.dev 
    <Directory "C:/workspace/woo-backend-laravel/application/">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

# If you want to use SSL, enable it by going to Menu > Apache > SSL > Enabled
llycmphe

llycmphe2#

我通过在Laragon社区获得一些帮助解决了这个问题
解决方法其实很简单。
编译Laragon时将其httpd.conf设置为拒绝覆盖文档根。
要编辑此内容,请检查

{LARAGON_ROOT}/bin/apache/httpd{other-version-details}/conf/httpd.conf

并且将第251到278行附近的文件的AllowOverride更改为All,然后重新启动Laragon服务器。
这样就解决了

注意事项:

您必须在代码Igniter中进行设置,例如您的index_page变量在

application/config/config.php

如果您有一个索引页,请在这里输入。
.htaccess文件包含以下内容:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /yourFolderName/index.php/$1 [L]

如果仍然不起作用,请找到httpd.conf中的所有AllowOverride None并将其更改为AllowOverride All。如果需要,请重新启动计算机。

相关问题