CodeIgniter URL suffix .html automatically for all URL

前端 未结 3 1860
陌清茗
陌清茗 2020-12-20 04:08

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

I can able to remove the index.php from the url & I also c

相关标签:
3条回答
  • 2020-12-20 04:41

    Change your config.php file

    $config['url_suffix'] = '.html';
    
    0 讨论(0)
  • 2020-12-20 04:44

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

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

    Use site_url()

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

    Or anchor()

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

    Note : Dont forget to load URL helper with $this->load->helper('url');.

    0 讨论(0)
  • 2020-12-20 04:47

    Just redefine the base_url function or make a new one. Look at the source of base_url method

    function _base_url($path = NULL) {
      return base_url() . $path . '.html';
    }
    
    0 讨论(0)
提交回复
热议问题