现在我网站的网址是:http://localhost/xxx/index.php/welcome/
我想将其更改为:http://localhost/xxx/welcome/
我的.htaccess文件:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我的config.php文件:
$config['base_url'] = 'http://localhost/xxx/';
$config['index_page'] = '';
但我的新网址仍无效。我应该在那里添加什么?
答案 0 :(得分:2)
您可以尝试以下mod_rewrite。它实际上是有效的,我在其中一个看过here的教程中看到了这个,这里是.htaccess。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /foldername/foldernameifapplicable/foldernameifapplicable
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [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>
答案 1 :(得分:0)
我不记得所做的所有更改,但是我遵循了以下教程,并且按照您的要求进行了操作。
https://www.youtube.com/watch?v=I752ofYu7ag
htaccess看起来像这样
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>