htaccess写入URL

时间:2016-08-07 02:17:41

标签: apache .htaccess mod-rewrite url-rewriting

我正在尝试使用htaccess文件为用户重写URL,以便用户可以轻松记住并确保地址栏保持冷静。我完成了重写 -

重新加入的网址

www.mysite.com/index.php?profile=2345

想要的实际网址

www.mysite.com/profile/2345

的.htaccess

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

1 个答案:

答案 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]