Forum Moderators: coopster & phranque

Message Too Old, No Replies

htaccess MOD question

redirect from string?

         

idiotgirl

2:51 am on Aug 19, 2001 (gmt 0)

10+ Year Member Top Contributors Of The Month



Isn't it possible to redirect using .htaccess by strings? Such as, a user habitually enters a string beginning with XXXXXX (on and on).

I'm not sure of the syntax to use wildcards for strings, especially if an extension may or may NOT be entered (XXXX.[extension]) or just nix any string with (XXXX*)

Then, it gets more confusing to screen any string BEGINNING with, or CONTAINING (whatever characters) you are trying to screen for.

I see there was a post a couple weeks ago without a response (that I can see.) Help, ideas, recommendations are very, very appreciated. I'd like to use .htaccess to redirect by strings.

Thanks!

Idiotgirl

mark_roach

8:42 am on Aug 19, 2001 (gmt 0)

10+ Year Member



I believe that within .htaccess you can use the full power of regular expresssions for pattern matching. It should be fairly straight forward for someone who understands regular expressions (not me !) to accomplish what you are trying to do.

If the XXXXX that you are referring to is from a referral string of /default.ida?XXXXX....., then that is a request from a webserver that is infected with the code red virus. It is probably best just to send it the 404 error.

idiotgirl

8:59 am on Aug 19, 2001 (gmt 0)

10+ Year Member Top Contributors Of The Month



Well... it's not just the default.ida thing (I got that handled). I've had several non code red strings entered by IP's from all over, asd well as some half-hearted hack attempts.

Though I'm flattered at all the attention, I'd just as soon they went somewhere else. So, I'd like to take the prelims of strings from my logfiles and use .htaccess to redirect.

I went and looked on Apache's site, but I'm confused as to what goes where as far as my syntax goes, what goes in the brackets for wildcards, etc. I want to keep it as general as possible, such as strings beginning with particular characters are redirected to:

[server...]

where a script parses, logs, and responds to the request (I already did that script.)

Thanks,

Idiotgirl

Bolotomus

4:19 am on Aug 20, 2001 (gmt 0)

10+ Year Member



You can do stuff like this in Apache

RedirectMatch .*\.php$ [cert.org...]

That would redirect all requests for files ending in ".php" to
CERT's homepage. Is that what you mean?

idiotgirl

3:35 am on Aug 21, 2001 (gmt 0)

10+ Year Member Top Contributors Of The Month



Dang... I just wrote this an lost it all. Okay, one more time:

Dear Bolotomus-

In re:
RedirectMatch .*\.php$ [cert.org...]

I think RedirectMatch just matches whatever was input and redirects to the same filename or call in another location, perhaps with a different file extension. I've been wrong more than once, so I may be waaay off on that one.

So, I'm wondering if what I really need to do is take a more aggressive step and do a:

RewriteEngine (blah)
RewriteCond (blah blah)
RewriteRule (blah blah blah)

which still leaves me virtually lost for correct wildcard syntax, the fact there may or may NOT be a file extension given, though now I'm lost in another direction ;)

While I can hold my own in several areas, this whole Apache htaccess rewrite business is unknown territory for me. I'm confused as to what is the thing that is appropriate in this case.

This htacess file is in my root directory, if that is somehow meaningful.

Thanks,

Idiotgirl

rcjordan

10:27 pm on Jan 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, I want to redirect all files in the directory (and any subdirectories) starting with the characters 'xx' and having the extention .shtml using htaccess. What's wrong with the following?

redirectMatch xx*\.shtml$ [mydomain.com...]

gethan

4:55 pm on Jan 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RC - is this a trick question? a missing .?

The pattern you have will basically grab all files that are like; xx.shtml or xxxxxxxxx.shtml etc and redirect (eg. any number of x's).

Try this: [perl]redirectMatch xx.*\.shtml$ [mydomain.com...]

Though it would also redirect files like hello-xx-test.shtml

rcjordan

5:26 pm on Jan 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>missing .

Not a trick, I tried it with/without the leading period. I'll try your suggestion now.

Actually, the file names have a the actual letters 'xx' in them. They are old military base locator files which I renamed with a leading 'xx' years ago when I acquired a site and replaced them. Recently, with the INK shift at AOL they've gone hot-hot-hot. I need to redirect to the new query page. All are in the same directory tree (including the new pages). The only unique characteristics they have are the xx.