-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from tanhongit/upgrade
Upgrade
- Loading branch information
Showing
5 changed files
with
96 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
RewriteEngine On | ||
|
||
# Redirect to HTTPS (uncomment the following lines if SSL is set up and you want to force HTTPS) | ||
# RewriteCond %{HTTPS} off | ||
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | ||
|
||
# Base directory | ||
RewriteBase / | ||
|
||
# Redirect the root domain to a specific controller and action (if needed) | ||
# RewriteRule ^$ index.php?controller=home&action=index [L,QSA] | ||
|
||
# Skip existing files from rewriting | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteRule ^([^/]+)/?$ index.php?controller=$1 [QSA,L] | ||
RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3 [NC,L] | ||
|
||
# Rewrite for clean URLs | ||
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?controller=$1&action=index [L,QSA] | ||
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?controller=$1&action=$2 [L,QSA] | ||
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([0-9]+)/?$ index.php?controller=$1&action=$2&id=$3 [L,QSA] | ||
|
||
# Handle requests for the root URL | ||
RewriteRule ^$ index.php [L,QSA] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Custom rewrite rules for yl_mvc_structure | ||
|
||
location / { | ||
try_files $uri $uri/ @rewrite; | ||
} | ||
|
||
location @rewrite { | ||
rewrite ^/([a-zA-Z0-9_-]+)/?$ /index.php?controller=$1&action=index last; | ||
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ /index.php?controller=$1&action=$2 last; | ||
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([0-9]+)/?$ /index.php?controller=$1&action=$2&id=$3 last; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
$request = $_SERVER['REQUEST_URI']; | ||
if (file_exists(__DIR__ . $request)) { | ||
return false; | ||
} else { | ||
if (preg_match('/^\/([^\/]+)\/([^\/]+)\/([^\/]+)$/', $request, $matches)) { | ||
$_GET['controller'] = $_REQUEST['controller'] = $matches[1]; | ||
$_GET['action'] = $_REQUEST['action'] = $matches[2]; | ||
$_GET['id'] = $_REQUEST['id'] = $matches[3]; | ||
include __DIR__ . '/index.php'; | ||
} elseif (preg_match('/^\/([^\/]+)\/([^\/]+)$/', $request, $matches)) { | ||
$_GET['controller'] = $_REQUEST['controller'] = $matches[1]; | ||
$_GET['action'] = $_REQUEST['action'] = $matches[2]; | ||
include __DIR__ . '/index.php'; | ||
} elseif (preg_match('/^\/([^\/]+)$/', $request, $matches)) { | ||
$_GET['controller'] = $_REQUEST['controller'] = $matches[1]; | ||
include __DIR__ . '/index.php'; | ||
} else { | ||
header("HTTP/1.0 404 Not Found"); | ||
echo '404 Not Found'; | ||
} | ||
} |