Forum Moderators: phranque

Message Too Old, No Replies

Using redirectmatch to remove "]" from bad links

         

madmatt69

6:11 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey there,

So I had a box on my site that encouraged people to link back to that page - except in that code I had an extra right bracket on each url! So it would look like mysite.com]

Now I found a bunch of people are linking to pages on my site with the ] and of course that results in 404s.

Anyways - I tried this redirect match rule and it's not working...Can't seem to get it.

Can anyone help me rewrite this?

RedirectMatch 301 ^/folder/[a-z0-9_-]*\]\.html$ http://www.example.com/folder/$1.html

[edited by: jdMorgan at 11:16 pm (utc) on Aug. 12, 2009]
[edit reason] example.com [/edit]

jdMorgan

11:15 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$1 through $9 refer to the first through ninth parenthesized sub-expressions in the pattern on the left. SInce you've got no parentheses here, $1 is empty or undefined. I also presume that there is always a filename present, so it's not necessary to use a full-wild-card quantifier. Correcting the code gives:

RedirectMatch 301 ^/folder/([a-z0-9_-]+)\]\.html$ http://www.example.com/folder/$1.html

See Apache mod_alias RedirectMatch documentation for more details.

Jim

madmatt69

11:28 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey jd thanks for the response!

I just gave it a shot, however I'm still getting a 404.

The urls have several dashes in them like [site.com...] - not sure if that could be conflicting?

We must be so close!

madmatt69

11:31 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wait - i got it! the ] is following the .html....let me try this again.

madmatt69

11:32 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Works! Thanks so much for the help :)