remove question mark and add variables with Query_string

Discuss practical ways rearrange URLs using mod_rewrite.

remove question mark and add variables with Query_string

Postby km1336 » Wed Aug 27, 2008 9:41 pm

I want to remove question mark(?) after the List/
and also the variableName.php would be variable so its not the same all the time it could be list.php or test.php or .. :
so this url
/List/?variableName.php?time=variables

redirect to:

/List/variableName.php?time=variables

what is wrong with this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ([^&]+)\.php& time=([^&]+)
RewriteRule ^List/$ List/%1\.php?time=%2

Thanks,
mk
km1336
 
Posts: 4
Joined: Wed Aug 27, 2008 9:23 pm

Postby richardk » Fri Aug 29, 2008 7:43 am

There is a space before time. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^([^\?&]+)\.php\?time=([^&]+)$
RewriteRule ^List/?$ /List/%1\.php?time=%2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby km1336 » Fri Aug 29, 2008 2:11 pm

Thanks Richard.

Does it work if the URL starts with HTTPS?

MK
km1336
 
Posts: 4
Joined: Wed Aug 27, 2008 9:23 pm

Postby richardk » Fri Aug 29, 2008 2:39 pm

It should. If you are having problems, try this mod_rewrite test.
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 79 guests

cron