homepage Welcome to WebmasterWorld Guest from 54.166.173.147
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Remove Querystring from URL
Remove Querystring from URL
colshine




msg:3562021
 3:43 pm on Jan 30, 2008 (gmt 0)

I'm trying to remove the the query string from one URL if the value of one of the variables is "Password hint". Here is what I have setup in .htaccess:

RewriteCond %{query_string} Password\+hint [NC]
RewriteRule ^links\.php links.php? [L]

I only want to do this on the links.php page but it doesn't work. There are no other rewrite rules in the .htaccess and I know that Apache is reading as I tested by adding a redirect.

Any help on where I am going wrong would be appreciated.

Thanks in advance.

 

jdMorgan




msg:3562038
 4:02 pm on Jan 30, 2008 (gmt 0)

Do you have any other working rewriterules?
Have you included the Options and RewriteEngine setup directives usually required by mod_rewrite?
Do you want to redirect and change the client's address bar, or just remove the query string so that it is not passed "links.php"?

Jim

colshine




msg:3562040
 4:06 pm on Jan 30, 2008 (gmt 0)

Yes - the rewrite mod is setup correctly and if I add other rules they work fine.

I want to redirect and change the client's address bar so that the query string is not passed to "links.php".

jdMorgan




msg:3562070
 4:32 pm on Jan 30, 2008 (gmt 0)

Then you need an external redirect:

RewriteCond %{QUERY_STRING} Password\+hint [NC]
RewriteRule ^links\.php$ http://www.example.com/links.php? [R=301,L]

I'd also recommend 'tightening-up' that query string pattern. If Password+hint is the variable name, then use
"&?Password\+hint=" as the pattern. If it's the value, then use "=Password\+hint&?". This will prevent problems in the future if you add a new string such as "New_password+hint" or "Password+hints" -- It's best to avoid laying mines for yourself to stumble on in the future.

Jim

colshine




msg:3562700
 10:33 am on Jan 31, 2008 (gmt 0)

I'm still having problems - with the rule you posted the query string still remains. I turned on rewrite logging and I get the following:

[dkt907153/sid#26c748][rid#11d2f08/initial] (2) init rewrite engine with requested uri /portal/links2.php
[dkt907153/sid#26c748][rid#11d2f08/initial] (1) pass through /portal/links2.php
[dkt907153/sid#26c748][rid#11d2f08/initial] (3) [perdir C:/temp/htdocs/] strip per-dir prefix: C:/temp/htdocs/portal/links2.php -> portal/links2.php
[dkt907153/sid#26c748][rid#11d2f08/initial] (3) [perdir C:/temp/htdocs/] applying pattern '^links2\.php$' to uri 'portal/links2.php'
[dkt907153/sid#26c748][rid#11d2f08/initial] (1) [perdir C:/temp/htdocs/] pass through C:/temp/htdocs/portal/links2.php

It looks like its not matching on the query string. Any ideas?

Thanks

jdMorgan




msg:3563157
 8:06 pm on Jan 31, 2008 (gmt 0)

No, it's not matching because the server sees the directory "/portal" ahead of links2.php, and that does not match the specified pattern. So what is "/portal"? -- You didn't mention it before.

Jim

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