Below is my .htaccess file
RewriteEngine On
RewriteRule ^(.*)/(.*)$ /manage/member/index.php?action=$1&id=$2 [L]
RewriteRule ^(.*)/(.*)/(.*)$ /manage/member/index.php?action=$1&id=$2&sub_action=$3 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)$ /manage/member/index.php?action=$1&id=$2&sub_action=$3&sub_id=$4 [L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
DirectoryIndex index.php
I got this $_GET on my first few lines
$action = $_GET['action'];
$id = $_GET['id'];
$sub_action = $_GET['sub_action'];
If i send in a url like
http://subdomain.mydomain.com/manage/member/edit/5
It can get the action as edit and id as 5
But if I send in
http://subdomain.mydomain.com/manage/member/edit/5/permission
It is unable to retrieve the sub_action as permission. what should i do to get it working
It retrieve 5 as the $1 and permission as the $2 and $3 is null.
What .htaccess should I put in to allow $3 and $4 to be null or value yet able retrieve via $_GET when they got value.
Keep your rules like this in /manage/.htaccess
:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /manage/
# skip rewrite rules for all files and directories
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)/?$ member/index.php?action=$1&id=$2 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ member/index.php?action=$1&id=$2&sub_action=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ member/index.php?action=$1&id=$2&sub_action=$3&sub_id=$4 [L,QSA]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.