I am passing one of the following URLs to a site an want it to split into the proper parameters.
http://example.com/storevar?search_term
http://example.com/storevar/?search_term
http://example.com/storevar
http://example.com/storevar/
http://example.com/storevar/search_term
http://example.com/storevar/search_term/
http://example.com/storevar/search_term/mode
http://example.com/storevar/search_term/mode/
Then they should pass the info to
http://example.com/process.php?store=$1&search=$2&mode=$3
Cuurently the following .HTACCESS file info handles the first 6 items, but not the "mode" info.
Options +FollowSymLinks
RewriteEngine On
# For /storevar?search_term and /storevar/?search_term
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /process.php?store=$1&search=%{QUERY_STRING} [L]
# For /storevar/search_term, /storevar/search_term/ and /st开发者_运维问答orevar/
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)(?:/([^/]+))?/?$ /process.php?store=$1&search=$2 [QSA,L]
My RewriteRule RegEx skills are poor, so I am not sure how to deal with all of the possible variations.
How would I add the "mode" variations?
For these:
http://example.com/storevar/search_term/mode
http://example.com/storevar/search_term/mode/
Use this one:
RewriteRule ^(?!process\.php)([^/]+)(?:/([^/]+)(?:/([^/]+))?)?/?$ /process.php?store=$1&search=$2&mode=$3 [L]
精彩评论