.htaccess mod_rewrite代码触发器

xe55xuns  于 2022-11-25  发布在  其他
关注(0)|答案(3)|浏览(142)

现在我的网站的URL是例如: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'] = '';

但是我的新网址仍然不起作用。我应该在那里添加什么呢?

4dc9hkyq

4dc9hkyq1#

你可以试试下面的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>
pbgvytdp

pbgvytdp2#

我不记得所做的所有更改,但我遵循了以下教程,它做了你问。

https://www.youtube.com/watch?v=I752ofYu7ag

htaccess看起来像这样

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>
9jyewag0

9jyewag03#

请输入您的密码,如果您有任何问题,请与我们联系。如果您有问题,请与我们联系。{1}/{2}问题是什么?{3}/{4}

相关问题