Regular expression mod_rewrite (htaccess)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geradeaus

    Regular expression mod_rewrite (htaccess)

    I use htaccess to rewrite the url using the following rules :

    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$
    index.php?lang= $1&page=$2&id=$ 3

    The only problem I have is when http://www.domain.com/admin is given,
    the "admin" is used as $1. How can I define the rule for every word
    given except "admin" ?

    Thanks in advance!

  • Philip Ronan

    #2
    Re: Regular expression mod_rewrite (htaccess)

    "Geradeaus" wrote:
    [color=blue]
    > I use htaccess to rewrite the url using the following rules :
    >
    > RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$
    > index.php?lang= $1&page=$2&id=$ 3
    >
    > The only problem I have is when http://www.domain.com/admin is given,
    > the "admin" is used as $1. How can I define the rule for every word
    > given except "admin" ?
    >
    > Thanks in advance!
    >[/color]

    Use a rewrite condition to exclude this case:
    <http://httpd.apache.or g/docs/1.3/mod/mod_rewrite.htm l#RewriteCond>

    Something like this perhaps:
    RewriteCond %{REQUEST_URI} !^admin.*$
    RewriteRule ...

    --
    phil [dot] ronan @ virgin [dot] net



    Comment

    • Geradeaus

      #3
      Re: Regular expression mod_rewrite (htaccess)

      Thanks , that's what I needed :o)

      Comment

      Working...