rewrite and redirect not working together

Discussion in 'Apache' started by jperezmt, May 23, 2008.

  1. #1
    I've looked at a million different forums and threads and google and everything but for some reason I can't get this to work.

    Options +FollowSymLinks
    RewriteEngine On
    #The following is the redirect
    
    RewriteRule ^/?page/(.*)/(.*)/$  /blog/$1/$2 [R=301,NC,L] #removes the slash, redirect
    RewriteRule ^/?page/(.*)/(.*)$  page.php?category=$1&title=$2 [NC,L] #rewrites the old url
    RewriteRule ^/?page/(.*)$  /blog/$1/ [R=301,NC,L]  #adds the slash to the category, one level, redirect
    RewriteRule ^/?([a-z0-9\-]+)$ /$1.php [NC,L] 
    RewriteRule ^/?([a-z0-9\-]+).php$ /$1/ [R=301,L] 
    RewriteRule ^/?([0-9]+)/news$  news.php?id=$1 [NC,L]
    
    Code (markup):

    There's my code. I'm trying to redirect /aboutus.php to /aboutus/ but I keep getting errors or the page just never loads. As soon as I remove this line

    RewriteRule ^/?([a-z0-9\-]+).php$ /$1/ [R=301,L]

    Everything works. I can access the page using /aboutus.php and I can access it using /aboutus/. Once I add the redirect, it stops working.

    Pleeeeeeaassssseeee Hellllp!:confused:
     
    jperezmt, May 23, 2008 IP
  2. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #2
    /aboutus/ is a webpage? Looks to me like a directory. /aboutus looks like a page. I can understand why you want /aboutus to redirect to /aboutus.php but why /aboutus.php to redirect to /aboutus?
     
    ForumJoiner, May 31, 2008 IP