Forum Moderators: phranque

Message Too Old, No Replies

Removing a query string

Yet another query string question

         

ccombs

7:31 pm on Feb 21, 2007 (gmt 0)

10+ Year Member



I have the following url that I need to remove the query string from.

url=http://www.example.com/BHIA/R/documents/Newsletters/2007/Q1/Newsletter.html?jmid=734790095

Will this do the trick?

RewriteCond $1 ^Newsletters/
RewriteCond %{query_STRING} .
rewriterule (.*) http://www.example.com/BHIA/R/documents/$1? [R=301,L]

[edited by: jatar_k at 8:22 pm (utc) on Feb. 21, 2007]
[edit reason] examplified [/edit]

jdMorgan

9:07 pm on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We'll need a few more specifics about where this code is located, and whether that URL and query string are the *only* ones that need to be redirected...

Jim

ccombs

3:13 am on Feb 22, 2007 (gmt 0)

10+ Year Member



This is the section of the httpd.conf you requested
...... this is the complete set of rewrite rules .....
<VirtualHost 172.**.11.10:80>
ServerName 172.**.11.10:80
#UseCanonicalName On
SuexecUserGroup root apache
DirectoryIndex index.html default.htm
<Directory "/var/www/html/">
Options Includes FollowSymLinks
AllowOverride none
Allow from all
Order allow,deny

RewriteEngine On
# Inserted to handle newsletters
RewriteCond $1 ^Newsletters/
RewriteCond %{query_STRING} .
Rewriterule (.*) http://www.example.com/BHIA/R/documents/$1? [R=301,L]
# End of newsletter insert
RewriteRule ^ach/?$ /BHIA/R?f=/documents/ach.pdf
RewriteRule ^cfaphp.htm$ / [R=301,L]

RewriteCond %{HTTP_HOST} example2.com [NC]
RewriteRule ^$ /fbphp/

RewriteRule ^imc/?$ http://%{HTTP_HOST}/BHIA/Do?h=bhia.CMS.Main&db=P&c=/&RefererURL=imc
RewriteRule ^vm/?$ http://%{HTTP_HOST}/BHIA/Do?h=bhia.CMS.Main&db=P&c=/&RefererURL=vm
RewriteRule ^fpl/?$ /

#RewriteCond %{HTTP_HOST} ^www.example2.com$
#RewriteRule ^$ /example2.html

#important rewrites below...
#match root page request

#important rewrites below...
#match root page request

#RewriteRule ^$ /Do?h=bhia.CMS.Main&db=P&c=/
#RewriteRule ^(.{1,5})/([\w\d\.\/]+\.html)$ /Do?h=bhia.CMS.Main&db=P&MarketChannel=&1&c=/$2

RewriteRule ^$ http://%{HTTP_HOST}/BHIA/

[edited by: jdMorgan at 2:26 pm (utc) on Feb. 22, 2007]
[edit reason] Removed specifics per TOS. [/edit]

ccombs

3:46 pm on Feb 22, 2007 (gmt 0)

10+ Year Member



http://www.example.com/BHIA/R/Newsletters/2007/Q1/Newsletters.html?jmid=99999 where the url will always be the same down to the
http://www.example.com/BHIA/R/Newsletters/ level. This particular path has not been used this way before, which is why the problem has occurred. An email service we are using is appending the jmid=9999 to the end of this url. We are trying to remove this query string as it is giving a not found based on a cms that is serving the other pages. This is the only document on this path that does not need any query strings.

I hope this gives you the additional info your requested.

jdMorgan

4:53 pm on Feb 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Given that, I'd suggest:

# Inserted to handle newsletters
RewriteCond %{QUERY_STRING} ^jmid=
RewriteRule ^/BHIA/R/Newsletters/(.*)$ http://www.example.com/BHIA/R/Newsletters/$1? [R=301,L]
# End of newsletter insert

This code in httpd.conf will redirect http://www.example.com/BHIA/R/Newsletters/<any_path>?jmid=<any_value> to
http://www.example.com/BHIA/R/Newsletters/<any_path>, removing the query string.

Note that the "documents" path given in your first example has apparently changed to "Newsletters" and this code reflects that change.

Jim

ccombs

2:31 am on Feb 23, 2007 (gmt 0)

10+ Year Member



It didnt work .....