How to remove a ? question mark in the middle of a url

Discuss practical ways rearrange URLs using mod_rewrite.

How to remove a ? question mark in the middle of a url

Postby archigeek » Sun Jun 08, 2008 8:01 am

I have this URL:

http://hostname/dir/file.php?string1/string2

and I want to turn it into

http://hostname/string1/string2


when i do this:
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^dir/file\.php$ . [R=301]

it turns the url to http://hostname/?string1/string2

How do I get rid of that "?" in the middle??
archigeek
 
Posts: 1
Joined: Sun Jun 08, 2008 7:57 am

Postby richardk » Mon Jun 09, 2008 1:00 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^dir/file\.php$ /%1? [NC,R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 52 guests

cron