.htaccess redirect, wildcard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zentz
    Confirmed User
    • Nov 2003
    • 8062

    #1

    .htaccess redirect, wildcard

    Is there a wildcard that i can use if i want to redirect all urls containing /somedir/blabla/694 ?

    example
    Redirect 301 /somedir/blabla/694-some-link http://www.website.com/blabla/some-link
    Redirect 301 /somedir2/blabla/694-some-other-link http://www.website.com/blabla/some-other-link
    Redirect 301 /somedir3/blabla/694-some-third-link http://www.website.com/blabla/some-third-link

    Basicly i want to remove "/somedirX" and "694-" from the urls. Is this possible to do this with 1 line of code or do i need 1 line for each url redirect?

    Thank you
    Last edited by zentz; 03-07-2010, 01:09 PM.
    Programs that owe me money ---- Epassporte.com ~ $2700 | Protraffic.com ~ $2600 | XonDemand.com ~ $3000

    Email: [email protected]
  • Kevsh
    Confirmed User
    • Dec 2004
    • 8619

    #2
    You can use regular expressions with redirects, so something like this - although I'm sure the syntax is not exactly correct, hopefully you get the idea:

    Redirect 301 /somedir[0-9]*/694-(.*) http://www.website.com/blabla/$2

    [0-9]* says to match any number between 0 and 9, zero or more times
    (.*) matches any character, zero or more times
    $2 will copy the contents matched by (.*) and preserve them

    These links may be of some help:
    http://www.gnc-web-creations.com/301-redirect.htm
    http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

    Comment

    • Iron Fist
      Too lazy to set a custom title
      • Dec 2006
      • 23400

      #3
      One and done.
      i like waffles

      Comment

      Working...