301 Redirect without fragment [duplicate]

2019-09-06 08:08发布

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?

2条回答
Viruses.
2楼-- · 2019-09-06 09:02

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

查看更多
Root(大扎)
3楼-- · 2019-09-06 09:07

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:

查看更多
登录 后发表回答