homepage Welcome to WebmasterWorld Guest from 54.145.191.14
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
removing sql query with modrewrite
tincan

10+ Year Member



 
Msg#: 124 posted 9:12 pm on Mar 10, 2003 (gmt 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.

http://www.foobar.com/ev.php?URL_ID=1527&URL_DO=DO_TOPIC&URL_SECTION=201&reload=1047330420

and I would like to change it to

http://www.foobar.com/minga

here is the code that I am using for modrewrite

#Used to rewrite url when clicking on a link

RewriteCond %{QUERY_STRING} URL_ID=1527&URL_DO=DO_TOPIC&URL_SECTION=201*
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:

http://foobar.com/minga?URL_ID=1527&URL_DO=DO_TOPIC&URL_SECTION=201&reload=1047330420

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

 

Brett_Tabke

WebmasterWorld Administrator brett_tabke us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 124 posted 10:50 am on Mar 11, 2003 (gmt 0)

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:

[foobar.com...]

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).

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 124 posted 12:55 pm on Mar 11, 2003 (gmt 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].

Andreas

tincan

10+ Year Member



 
Msg#: 124 posted 4:17 pm on Mar 13, 2003 (gmt 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 %{QUERY_STRING} URL_ID=1527&URL_DO=DO_TOPIC&URL_SECTION=201*
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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved