Replace characters from a URL via .Htaccess

0

I have the following URL template:

http://dominio.com.br/cgi-bin/wiki.pl?Palavra
http://dominio.com.br/cgi-bin/wiki.pl?Outra_Palavra

I need to redirect to this new template:

http://dominio.com.br/#Palavra
http://dominio.com.br/#Outra_Palavra

I want to replace the cgi-bin/wiki.pl?Palavra stretch with #Palavra when redirecting.

My .htaccess is currently like this:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{HTTP_HOST} ^dominio.com.br
RewriteRule ^ http://www.dominio.com.br%{REQUEST_URI} [L,R=301]
RewriteRule ^cgi-bin/wiki.pl?(.*)$ /#$1 [R=301,NC,L,NE]
</IfModule>

Using this current .htaccess template, you are redirecting from: http://dominio.com.br/cgi-bin/wiki.pl?Palavra to: http://dominio.com.br/#?Palavra

Note that the question is still present in the URL after the redirect, but I need it to look like this: http://dominio.com.br/#Palavra

Note: It seems that anyone who created the first URL structure (which in my case it was not me) used the "Key" of the Query String as a value, and for this reason I am not able to retrieve the Key to use in the new structure of URLs. If the URL was http://dominio.com.br/cgi-bin/wiki.pl?chave=Palavra it would be easier to resolve, but the way it is currently I can not resolve.

Does anyone know how to solve this?

    
asked by anonymous 21.05.2017 / 01:03

1 answer

0

I found the solution. Followed .htaccess updated:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{HTTP_HOST} ^dominio.com.br
RewriteRule ^ http://www.dominio.com.br%{REQUEST_URI} [L,R=301]
RewriteRule ^cgi\-bin/wiki\.pl$ /\#%{QUERY_STRING} [QSD,R=301,L,NE]
</IfModule>
    
21.05.2017 / 20:17