Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

removing sql query with modrewrite

9:12 pm on Mar 10, 2003 (gmt 0)

New User

10+ Year Member

joined:Mar 10, 2003
votes: 0

I have been trying to have modrewrite manipulate urls that have a mysql query string in it. All seems to be working ok, but I get the mysql query string in the url and I would like to remove it.

This would be the original url.


and I would like to change it to


here is the code that I am using for modrewrite

#Used to rewrite url when clicking on a link

RewriteCond %{THE_REQUEST}!minga
RewriteRule ^(.*) /minga [R,L]

#Rewrite rule redirecting link.

RewriteRule ^minga/ /minga [R,L]
RewriteRule ^minga /ev.php?URL_ID=1527&URL_DO=DO_TOPIC&URL_SECTION=201 [PT,L,NC]

Now with this I get the following url:


Anyone have any ideas on how to remove the query string from the url?

10:50 am on Mar 11, 2003 (gmt 0)

Administrator from US 

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 21, 1999
votes: 90

Welcome to the board Tincan.

First, it looks like to me that the code is backwards? Don't you really want to be doing something like:


and results in a call to your sql query string?

I can't see why, you would want to go the other way. For example, look at the url, that is process by something like:

RewriteRule ^forum([0-9]+)/([0-9\-]+)\.htm(.*) read.cgi?forum=$1&discussion=$2$3 [T=application/x-httpd-cgi]

Which xlates the static url into a cgi call.

Isn't that what you are after? (If not - I am missing the point).

12:55 pm on Mar 11, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
votes: 0

Msg7 [webmasterworld.com] in Bag-O-Tricks for PHP II - some code snippets that should be helpful for all in creating dynamic sites [webmasterworld.com] explains what mod_rewrite [httpd.apache.org] does and what it doesn´t do.

Msg4 [webmasterworld.com] explains about an easy solution to getting rid of those query strings [webmasterworld.com].


4:17 pm on Mar 13, 2003 (gmt 0)

New User

10+ Year Member

joined:Mar 10, 2003
votes: 0

Thanks for your replies.

I figured out how to remove the query string in the url by putting a? at the end of the rewrite rule. So now all is working perfectly. Here is the code.

RewriteCond %{THE_REQUEST}!minga

# the? at the end of the line removes the query string.

RewriteRule ^(.*) /minga? [R,L]
RewriteRule ^minga/ /minga [R,L]
RewriteRule ^minga /ev.php?URL_ID=1527&URL_DO=DO_TOPIC&URL_SECTION=201 [PT,L,NC]

Thanks again.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members