Forum Moderators: phranque

Message Too Old, No Replies

getting rid of a ? when redirecting page.pl?

redirecting a page

         

Saguaro2

1:37 am on Oct 13, 2008 (gmt 0)

10+ Year Member



Hello,

I have read many posts that almost solve my problem but not quite.

I am trying to 301 redirect page.pl? to newpage.html

The code I am using is:

RedirectMatch permanent ^/cgi-bin/directory/page.pl* http://www.example.com/newpage.html

This does redirect but the url reads http://www.example.com/newpage.html?

Is there any way to get rid of the ? at the end of the URL?

Thanks.

jdMorgan

2:34 am on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use mod_rewrite, and append a "?" to the substitution URL. In this case, the "?" is a token that says "clear the query string (and remove the "?" itself. In www.example.com/.htaccess:

Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^cgi-bin/directory/page\.pl$ http://www.example.com/newpage.html? [R=301,L]

(All syntax discrepancies between this code and your RedirectMatch code are intentional.)

Jim

Saguaro2

8:43 pm on Oct 13, 2008 (gmt 0)

10+ Year Member



Thanks Jim

Your RewriteRule worked great.