apache - .htaccess Rewrite Rule Possibility? -


i'm having little issue. 1 of clients sent out email blast 6500 people, included invalid link pdf file.

the link simply: http://theirsite.com/pdf/thepdf.pdf%20

so, i'd able htaccess rewrite them valid http://theirsite.com/pdf/thepdf.pdf file

so far, i've tried not work.

here i've tried far:

rewriterule ^(/pdf/thepdf.pdf[%20|\s]+)$ /pdf/thepdf.pdf [r=301,l]  rewriterule /pdf/thepdf.pdf([%20|\s]+)$ /pdf/thepdf.pdf [r=301,l]  rewriterule /pdf/thepdf.pdf%20 /pdf/thepdf.pdf [r=301,l]  rewriterule /pdf/thepdf.pdf%20 /pdf/thepdf.pdf [r=301,l] rewriterule /pdf/thepdf.pdf  /pdf/thepdf.pdf [r=301,l]  rewriterule /pdf/thepdf.pdf(.+?) /pdf/thepdf.pdf [r=301,l] 

something note here, if click original link, remove %20 , put in space, rewrite works.

just not work %20

since .htaccess there should not mandatory forward slash @ beginning of match rule. try this:

rewriteengine on rewriterule ^/?pdf/thepdf\.pdf\s+$ /pdf/thepdf.pdf [r=301,l] 

note:

  • i put /? @ beginning of match rule general practice make rule work in either host config context or .htaccess context. since / required if rule in host config.
  • you should escape . before .pdf otherwise act wildcard match.
  • i added anchors (^ , $) @ beginning , end of match make sure matches entire resource string

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -