0
我有一個PHP腳本根據GET參數輸出不同的東西。重寫和區分同一級別上的兩個GET參數
PHP代碼:
if((isset($_GET['channel'])) && (!isset($_GET['profile']) && !isset($_GET['c']) && !isset($_GET['b']) && !isset($_GET['highlight']) && !isset($_GET['broadcast']))){
echo 'Output1';
} elseif((isset($_GET['channel']) && isset($_GET['profile'])) && (!isset($_GET['c']) && !isset($_GET['b']) && !isset($_GET['highlight']) && !isset($_GET['broadcast']))) {
echo 'Output2';
} elseif((isset($_GET['channel']) && isset($_GET['c']) && isset($_GET['highlight'])) && (!isset($_GET['profile']) && !isset($_GET['b']) && !isset($_GET['broadcast']))) {
echo 'Output3';
} elseif((isset($_GET['channel']) && isset($_GET['b']) && isset($_GET['broadcast'])) && (!isset($_GET['profile']) && !isset($_GET['c']) && !isset($_GET['hightlight']))) {
echo 'Output4';
}
當前的.htaccess:
RewriteEngine on
## If the request is for a valid directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
## If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f [OR]
## If the request is for a valid link
RewriteCond %{REQUEST_FILENAME} -l
## don't do anything
RewriteRule^- [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ ?channel=$1&b=$2&broadcast=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ ?channel=$1&c=$2&highlight=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ ?channel=$1&profile=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ ?channel=$1 [L,QSA]
我怎麼需要它的工作:
example.com/channel/c/12345輸出「輸出3 「
example.com/channel/b/12345 outputs」輸出4 「
怎麼現在的工作:
example.com/channel/c/12345輸出」 輸出4 「
example.com/channel/b/12345輸出」 輸出4 「
有沒有什麼聰明的方法可以讓我像這樣工作?
提前致謝!
這工作!謝謝你幫助我。 接受答案! –