gpt4 book ai didi

php - 基于 CodeIgniter URL 段

转载 作者:可可西里 更新时间:2023-11-01 01:05:50 26 4
gpt4 key购买 nike

我希望我的 URL 看起来像:www.domain.com/controller/view/args 而不是 index.php?/controller/view/args。实际上,我从不想要验证 url“index.php?...”。任何人都可以提示我如何强制执行此行为,因为当我这样做时:A) redirect()B) 手动输入“index.php””。 .."url 变成了那个丑陋的模式。

这是我的 .htaccess 文件(我不知道我是否需要这个文件,只是从互联网上复制粘贴):

#http://codeigniter.com/wiki/Godaddy_Installaton_Tips/

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

这是我的 config.php:

$config['base_url'] = '';
$config['index_page'] = 'index.php?';
$config['uri_protocol'] = 'AUTO';
$config['enable_query_strings'] = FALSE;

这就是改变行为的原因:

redirect('...blah', 'either location or refresh');

最佳答案

您实际上需要 codeigniter 目录根目录中的 .htaccess 文件(index.php 所在的位置)。 .htaccess 文件负责管理参数的重写。如果您查询 yoursite.com/?controller/model,它将像 index.php 一样工作。 “?controller/...”仍会存在,但只要您记得始终链接到非 index.php 版本,index.php 就不会存在。包含的 .htaccess 在大多数情况下都可以使用(尤其是对于 apache)。如果 codeigniter 不在您站点的根目录中(即 public_html/somedir/{codeigniter_goes_here}),您可能需要进行修改。

关于php - 基于 CodeIgniter URL 段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11253226/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com