.htaccess doesn't work properly

Discussion in 'PHP' started by dooper, Jan 8, 2013.

  1. #1
    I have some url that needs to redirect one by one in .htaccess. however I didn't get it work. it says too many redirection. the old url was serving "/" with slash. new sytem doesn't have slash. So I have to redirect to non-slash version.
    could you check my htaccess if there is anything wrong. Thanks.

    RewriteEngine on
    #redirect index.php main domain name
    RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.php$ http://www.site.com/$1 [R=301,L]

    #redirect tp without extension version if someone type with .php extension
    RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(([^/]+/)*[^.]+)\.php http://www.site.com/$1 [R=301,L]

    #www redirect to with www version
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    # .php remove .php extension
    RewriteRule %{REQUEST_URI} !\.(gif|jpe?g|png|css|js|zip)$
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

    redirect 301 /page/ http://www.site.com/page <--- This line needs to work.
     
    dooper, Jan 8, 2013 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Add this to to your older .htaccess file
    RewriteBase /
    PHP:
    ...and start over
     
    Last edited: Jan 8, 2013
    MyVodaFone, Jan 8, 2013 IP
  3. links123

    links123 Active Member

    Messages:
    104
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    You should replace this \ slash. then it will work.
     
    links123, Jan 9, 2013 IP