我想在使用 mod_rewrite 时通过 url 传递数据。我在 stackoverflow 和其他网站上阅读了许多链接,但找不到解决方案。
结果网址为:
http://example.com/Path/logmanagement/view/1/?name=3&type=klik
print_r 返回:
Array ( [action] => logbeheer [do] => view [id] => 1 )
目前我有这个htaccess:
Options -Indexes
ServerSignature Off
RewriteEngine On
#RewriteBase /
##this part is what I tried##
RewriteCond %{QUERY_STRING} ^name=(\d+)&type=(\w+)$
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)$ index.php?action=$1&do=$2&id=$3&name=%1&type=%2
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)/$ index.php?action=$1&do=$2&id=$3&name=%1&type=%2
##end this part##
# URL Filtering helps stop some hack attempts
#IF the URI contains a "http:"
RewriteCond %{QUERY_STRING} http\: [OR]
#OR if the URI contains a "["
RewriteCond %{QUERY_STRING} \[ [OR]
#OR if the URI contains a "]"
RewriteCond %{QUERY_STRING} \] [OR]
#OR if the URI contains a "<script>"
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
#OR script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^.*$ - [F,L]
# END Filtering
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z_0-9-]+)$ index.php?action=$1
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)$ index.php?action=$1&do=$2
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)$ index.php?action=$1&do=$2&id=$3
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)$ index.php?action=$1&do=$2&id=$3&id2=$4
RewriteRule ^([a-zA-Z_0-9-]+)/$ index.php?action=$1
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/$ index.php?action=$1&do=$2
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)/$ index.php?action=$1&do=$2&id=$3
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)/$ index.php?action=$1&do=$2&id=$3&id2=$4
RewriteRule ^([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)/([a-zA-Z_0-9-+]+)/$ index.php?action=$1&do=$2&id=$3&name=%1&type=%2
# Fixed upload issues for the milti file upload
SetEnvIfNoCase Content-Type "^multipart/form-data;" "MODSEC_NOPOSTBUFFERING=Do not buffer file uploads"