0

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.example.com/iphone-ipad-mobile-apps-portfolio.html#Gigguid

To the following URL:

http://www.example.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?

MrWhite
  • 43,179
  • 8
  • 60
  • 84
Chetan
  • 44
  • 5

2 Answers2

3

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:

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
-1

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.example.com/iphone-ipad-mobile-apps-portfolio.html?id=3#Gigguid

redirect to:

http://www.example.com/portfolio.html?id=3#Gigguid
MrWhite
  • 43,179
  • 8
  • 60
  • 84
mohammad mohsenipur
  • 3,218
  • 2
  • 17
  • 22
  • The OP wants to _remove_ the fragment identifier, not preserve it, as in your example. This is what's happening by default. – MrWhite Aug 29 '22 at 17:30