删除子文件夹的代码点火器中的index.php
我有一些问题。在开发中,我使用PHP7,我的网站运行良好。但在使用PHP5.4的生产环境中,我在删除index.php时遇到了问题。我的网站托管在子文件夹中,就像删除子文件夹的代码点火器中的index.php,php,.htaccess,codeigniter,codeigniter-3,Php,.htaccess,Codeigniter,Codeigniter 3,我有一些问题。在开发中,我使用PHP7,我的网站运行良好。但在使用PHP5.4的生产环境中,我在删除index.php时遇到了问题。我的网站托管在子文件夹中,就像myhost/mywebsitefolder 问题是在使用url函数时。例如,当我访问“dashboard”页面时,它将重定向到“login”页面,url类似于myhost/mywebsitefolder/login,它返回404未找到页面。当我在登录之前添加index.php(myhost/mywebsitefolder/index.
myhost/mywebsitefolder
问题是在使用url函数时。例如,当我访问“dashboard”页面时,它将重定向到“login”页面,url类似于myhost/mywebsitefolder/login
,它返回404未找到页面。当我在登录之前添加index.php(myhost/mywebsitefolder/index.php/login
)时,它工作得很好,但我必须通过添加index.php替换所有url。有什么解决办法吗。我的.htaccess就是这样
RewriteEngine on
RewriteBase /mywebsitefolder/
RewriteCond $1 !^(index.php|resources|gallery|json|slider|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
在点之前用斜线,如:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /mywebsitefolder
RewriteCond $1 !^(index\.php|resources|gallery|json|slider|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
有时您需要在重写模块中启用它,请运行“apache2 enable module rewrite”:
您需要重新启动Web服务器以应用更改:
sudo service apache2 restart
希望它能起作用
如果没有,则有其他线程存在相同的问题,您可以查看:
-
-
-尝试在
RewriteRule^(.*)$index.php?/$1[L,QSA]
行中添加问号。谢谢,我想问题出在我的apache模块中
sudo a2enmod rewrite
sudo service apache2 restart