htaccess: Redirect a Dynamic URL - Show only Static URL - Double Content

自古美人都是妖i 提交于 2020-01-25 22:13:36

问题


I have a rewrite rule to get clean urls.. the only problem is, google shows some dynamic url and i dont want to serve dynamic urls.

What I want: if a user types in the dynamic url, he gets redirected to the clean url.. example:

    http://www.example.com/?index=bananas 
    (if someone types that in, he gets redirect to the url above)
    http://www.examplcom/bananas/

this is my htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond $1 !apple\+banana
RewriteRule ^(.*)\+apple\+banana/$ ?q=$1 [L]

thank you!!


回答1:


Ok, retry :)

RewriteCond %{QUERY_STRING} ^index=([a-zA-Z0-9]+)$
RewriteRule ^/ /%1? [R=302,L]


来源:https://stackoverflow.com/questions/2611506/htaccess-redirect-a-dynamic-url-show-only-static-url-double-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!