日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 路由 隐藏index,CI中路由与伪静态、隐藏index.php(十四)

發布時間:2023/12/10 php 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 路由 隐藏index,CI中路由与伪静态、隐藏index.php(十四) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1,設置路由

默認控制器設置文件

application/config/routes.php$route['default_controller']?=?'welcome';

我們新建一個控制器文件

application/controllers/article.php<?php

class?Article?extends?CI_Controller{

public?function?index(){

echo?"這是一個Article的index方法";

}

}

訪問:index.php/article/index

在寫一個方法public?function?show($id){

echo?'這是文章'.$id;

}

訪問:index.php/article/show/4

或者index.php/article/show/4.html

我們現在路由配置文件里面寫一個正則

application/config/routes.php//index.php/news/201654/4.html

$route['news/[\d]{6}/([\d]+)\.html']='article/show/$1';

2,去掉index.php

前提是需要確定Apache開啟rewrite模塊

wamp/bin/apache/apache2.4.9/conf/httpd.conf

打開注釋LoadModule?rewrite_module?modules/mod_rewrite.so

讓后修改項目配置文件.htaccess文件,添加代碼

RewriteEngine?on

RewriteCond?%{REQUEST_FILENAME}?!-d

RewriteCond?%{REQUEST_FILENAME}?!-f

RewriteRule?^(.*)$?index.php/$1?[QSA,PT,L]

這樣就可以去掉index.php

如果訪問錯誤,再去application/config/config.php文件里$config['index_page']?=?'index.php';//把index.php去掉

總結

以上是生活随笔為你收集整理的php 路由 隐藏index,CI中路由与伪静态、隐藏index.php(十四)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。