Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎样才能重定向一个像 http://sample.com/view_image?v=random key like youtube
http://sample.com/view_image?v=random key like youtube
到
http://sample.com/view/?v=random key like youtube?
http://sample.com/view/?v=random key like youtube
在文档根目录的 htaccess 文件中,您可以执行以下任一操作:
Redirect 301 /view_image /view/
或者
RedirectMatch 301 ^/view_image$ /view/
或者,如果您已经有规则并且不希望 mod_alias 指令与您现有的重写规则冲突,则可以使用 mod_rewrite:
RewritRule ^/?view_iamge$ /view/ [L]
在所有三种情况下,?v=something查询字符串都会自动附加到末尾。
?v=something