所有URL的CodeIgniter URL后缀.html [英] CodeIgniter URL suffix .html automatically for all URL

查看:1009
本文介绍了所有URL的CodeIgniter URL后缀.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CodeIgniter的新用户。
我在我的localhost设置CI例如。 localhost / MyProjects / CodeIgniter / welcome / index

I am new in CodeIgniter. I setup CI in my localhost Eg. localhost/MyProjects/CodeIgniter/welcome/index

我可以从url&我也完成了.html后缀
所以,我可以访问localhost / MyProjects / CodeIgniter / welcome / index.html&它工作正常。

I can able to remove the index.php from the url & I also completed the .html suffix So, I can able to visit localhost/MyProjects/CodeIgniter/welcome/index.html & Its working properly.

所以我使用我的标签:

<a href="<?php echo base_url(); ?>welcome/register.html">Register</a>

但是,我不想手动使用我的链接中的.html。

But, I dont want to use the .html in my link manually.

有任何解决方案自动显示我的访问者.html后缀。 localhost / MyProjects / CodeIgniter / welcome / index.html或localhost / MyProjects / CodeIgniter / welcome / about.html Etc

have any solution to show my visitor .html suffix automatically Eg. localhost/MyProjects/CodeIgniter/welcome/index.html Or localhost/MyProjects/CodeIgniter/welcome/about.html Etc

这里是我的htaccess http://pastebin.com/cXUFjvbp

Here is my htaccess http://pastebin.com/cXUFjvbp

推荐答案

只需编辑 config.php .....

Just edit url_suffix in config.php .....

$config['url_suffix'] = '.html';

使用 site_url()

<!-- No need .html -->
<a href="<?php echo site_url('welcome/register'); ?>">Register</a>
<!-- <a href="http://domain/welcome/register.html">Register</a> -->

anchor()

// No need .html
echo anchor('welcome/register', 'Register');
// <a href="http://domain/welcome/register.html">Register</a>

请注意 :不要忘记加载网址助手 $ this-> load-> helper('url');

这篇关于所有URL的CodeIgniter URL后缀.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆