Remove “index.php” from URL - Codeigniter

前端 未结 12 1182
清酒与你
清酒与你 2020-12-03 16:05

I\'ve looked in the documentation of Codeigniter of removing the index.php from the URL when accessing different views, the code shows how to remove it with apa

12条回答
  •  萌比男神i
    2020-12-03 16:17

    From the words of the CodeIgniter documentation

    By default, the index.php file will be included in your URLs:

    example.com/index.php/news/article/my_article You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

    you can find it here: http://codeigniter.com/user_guide/general/urls.html

提交回复
热议问题