Skip to content

Commit 51af975

Browse files
committed
Chapter-03 router
1 parent b411d33 commit 51af975

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

chapter-3/.htaccess

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RewriteEngine on
2+
RewriteCond %{REQUEST_FILENAME} !-d
3+
RewriteCond %{REQUEST_FILENAME} !-f
4+
RewriteRule ^(.*)$ index.php/$1 [L]
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
/**
3+
* config.php
4+
*/
25
return array(
3-
//'配置项'=>'配置值'
6+
'URL_ROUTER_ON' => true
47
);
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
<?php
2+
/**
3+
* config.php
4+
*/
25
return array(
3-
//'配置项'=>'配置值'
6+
'URL_ROUTE_RULES' => array(
7+
'/^posts\/(\d{4})\/(\d{2})\/(\d{2})$/' => 'Index/index?year=:1&month=:2&day=1',
8+
'posts/:year/:month/:day' => 'Index/index',
9+
'posts/:id' => 'Index/index',
10+
'posts/read/:id' => '/posts/:1',
11+
),
12+
'URL_MAP_RULES' => array(
13+
'site/welcome' => 'Index/index?from=seo'
14+
)
415
);

chapter-3/Application/Home/Controller/IndexController.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ class IndexController extends Controller
77
{
88
public function index()
99
{
10-
echo 1;
10+
echo $_GET['from'];
1111
}
1212
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy