【问题标题】:mod_rewrite CodeIgnitermod_rewrite CodeIgniter
【发布时间】:2015-06-19 15:25:53
【问题描述】:

现在我网站的 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'] = '';

但我的新网址仍然无法使用。我应该在那里添加什么?

【问题讨论】:

  • 这个问题可能会帮助stackoverflow.com/questions/30933255/… 删除 index.php 已经在堆栈溢出中被问了数百次。不要触摸应用程序文件夹中的 htaccess。
  • 真的有用吗?你为什么拒绝访问该网站? Require all denied

标签: .htaccess codeigniter mod-rewrite


【解决方案1】:

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

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会失效。
  • 哎呀。对此感到抱歉。我会正确编辑它,顺便说一句,谢谢你的提醒,
【解决方案2】:

我不记得所做的所有更改,但我按照以下教程进行了操作,并按照您的要求进行了操作。

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

htaccess 看起来像这样

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

【讨论】:

    猜你喜欢
    • 2012-11-01
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 2012-11-12
    • 2011-08-10
    相关资源
    最近更新 更多