mod_rewrire can't find the existing file!

Discussion in 'Apache' started by tutunmayan, Dec 7, 2009.

  1. #1
    Hi I have a .htaccess file tested on many different servers. Up to now everything was fine.

    On a new server installation I get an error

    The requested URL /home/site/public_html/index.php was not found on this server. (Calling url is 192.168.2.200/~site/en/)

    Infact the file exists but there is some thing missing in the path. It should be

    /usr/home/site/public_html/index.php


    More information: --------------

    Site is hosted at 192.168.2.200/~site/
    User director in the file system is /usr/home/site
    System: FreeBSD est.abegp.gov.tr 6.4-RELEASE FreeBSD 6.4-RELEASE #0: Wed Nov 26 08:37:42 UTC 2008 root@palmer.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP amd64
    Server API: Apache 2.0 Handler

    .htacces file part:

    RewriteEngine on

    DirectoryIndex index.html index.php

    Options -Indexes

    RewriteRule ^([a-z]{2})/?$ index.php?lang=$1&
     
    tutunmayan, Dec 7, 2009 IP
  2. tutunmayan

    tutunmayan Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    OK...
    I have too many rules like "RewriteRule ^([a-z]{2})/?$ index.php?lang=$1& " in .htaccess file.
    instead of adding /usr/home/site/public_html/ before file names of all rules, is there any easy way of doing this?

    for example adding a last rule at the end of the file that adds this path to files.
     
    tutunmayan, Dec 8, 2009 IP
  3. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #3
    before your rewrite rules
    add the line

    RewriteBase /

    that would be server document root for your web site
    if you have your .htaccess in a subfolder /sub/subfolder2/
    then you have to adjust accordingly
    i.e.:something like

    RewriteBase /sub/subfolder2/
     
    hans, Dec 8, 2009 IP
  4. tutunmayan

    tutunmayan Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the replies, but problem goes on.

    I've changed rewritebase now this error comes out:

    /usr/home/site/public_html/index.php was not found on this server.


    I know that the file exists there. When I login with filezilla through ssh Remote Site window is /usr/home/site/public_html/ and index.php is there


    any ideas???
     
    tutunmayan, Dec 8, 2009 IP
  5. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #5
    here below on apache 2.2 opensuse
    the code I had to add before each rewrite line in my htaccess

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
     
    hans, Dec 8, 2009 IP
  6. tutunmayan

    tutunmayan Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    When I added Options +FollowSymlinks I get Internal Server Error !#%!
     
    tutunmayan, Dec 8, 2009 IP