开发者

htaccess rewrite urls

I have a link http://mywebsite.com/?view=3457373673863568 everything after the view= will change depending on who gets it. how can开发者_JAVA百科 I redirect them to another page on the site i.e. http://mywebsite.com/mypage

something like:

RewriteRule http://mywebsite.com/?view=(?) http://mywebsite.com/mypage/


mod_rewrite parses the URL and the rules only see the path, not the query string. The query string is stored in the variable QUERY_STRING, which needs to be matched separately.

RewriteCond %{QUERY_STRING} ^view=
RewriteRule ^$ /mypage [L]

This matches the empty path (i.e., / on your site) and any query string that starts with view=. The query string will be passed implicitly to the target page.

If you want an external redirect so the user browser shows /mypage, use the [R] flag (change [L] to [L,R]).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜