Skip to main content
Inspiring
June 11, 2009
Question

Regular Expressions

  • June 11, 2009
  • 2 replies
  • 622 views

Hi Community!

This is not exactly a CF 8 question but rather a question about regular expressions. I am currently working on the httpd.conf file in ISAPI URL re-writing and I am having a hard time getting rid of text that shows after a "?" in a URL.

This is my regular expression:

RewriteRule ^/robots\.txt.*$ /\?.* [L,R=301]

Please note that i the URL to be re-written I am using \?.* so it reads the ? with its alternate meaning opposed to meaning "pass a parameter"

If I have the url:

www.url.com/?blahblah

It redirects to my homepage but it keeps the text blahblah in the re-written URL. This is obviously going to cause problems with the indexing of my pages and the "spidering" process.

Does anybody have some thoughts?

Thanks!

Ysais.

This topic has been closed for replies.

2 replies

Participating Frequently
June 17, 2009

The second parameter of RewriteRule is the replacement string but in

your case it looks like another regular expression.

Also, by default I think R uses the original query string for the

redirection URL. If you want a blank query string you will need to

explicitly append a question mark to the end of the new URL:

RewriteRule test.html /?

Mack

Inspiring
June 16, 2009

I do not see how the RewriteRule that you have specified here would accomplish the substitution that you are describing.

Here's an online tester that you can use to work out the problems in your rewrite rules:

http://civilolydnad.se/projects/rewriterule/

Saves a lot of time.