我正在尝试使用htaccess文件为用户重写URL,以便用户可以轻松记住并确保地址栏保持冷静。我完成了重写 -
www.mysite.com/index.php?profile=2345
www.mysite.com/profile/2345
RewriteRule ^profile/([0-9]+)/?$ index.php?profile=$1 [NC,L]
** 1。多个**
www.mysite.com/profile=2345&a=65&b=34&c=7&d=54
到
www.mysite.com/profile/2345/a/65/b/34/c/7/d/54
2。是否有可能更进一步?
profile.mysite.com/2345/a/65/b/34/c/7/d/54
答案 0 :(得分:0)
1
RewriteRule ^profile/([0-9]+)/a/([0-9]+)/b/([0-9]+)/c/([0-9]+)/d/([0-9]+)/?$ index.php?profile=$1&a=$2&b=$3&c=$4&d=$5 [NC,L]
2
RewriteCond %{HTTP_HOST} ^profile\.mysite\.com$
RewriteRule ^([0-9]+)/a/([0-9]+)/b/([0-9]+)/c/([0-9]+)/d/([0-9]+)/?$ index.php?profile=$1&a=$2&b=$3&c=$4&d=$5 [NC,L]
3
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3&$4=$5&$6=$7&$8=$9 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3&$4=$5&$6=$7 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3&$4=$5 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/?$ index.php?%1=$1 [NC,L]