301 Redirect without fragment [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-13 04:09:56

问题


Possible Duplicate:
URL Fragment and 302 redirects

I need to help regarding the 301 Redirect without Special character.

For example, I want to redirect the following URL:

http://www.iphoneapplications.us/iphone-ipad-mobile-apps-portfolio.html#Gigguid

To the following URL:

http://www.i-phonedeveloper.com/portfolio.html

I have changed .htaccess to perform the redirect, but the fragment #Gigguid remains in the final URL. How can this be fixed?


回答1:


The current HTTP standard does not allow you to do such a redirect - at least the HTTP client is refusing to do so. Your browser will always add the #... part to the redirect URI.

This #.... is called Fragement by the way, special character is not saying much (a URI has many special characters like :, %, ? and &), better use the right name for this.

The next HTTP standard release will likely take care of that issue but it's still a bit fragile, the meaning has changed sometimes in the draft and as I can not look into the future it's yet too early how this will be done with the next stable release of HTTP.

See as well this question for more information:

  • URL Fragment and 302 redirects
  • PHP Location Header Ignore Hash



回答2:


you can Use This code In htaccess

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase   /
RewriteCond %{REQUEST_URI} ^(.*)-(.*)\.(html|htm|php)$
RewriteRule ^ /%2.%3 [R=301,L]

sample :

http://www.iphoneapplications.us/iphone-ipad-mobile-apps-portfolio.html?id=3#Gigguid

redirect to:

http://www.i-phonedeveloper.com/portfolio.html?id=3#Gigguid



来源:https://stackoverflow.com/questions/14477154/301-redirect-without-fragment

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