Simple problem with mod_rewrite in the Fat Free Framework

前端 未结 7 2446
悲哀的现实
悲哀的现实 2020-12-18 02:42

I am trying to setup and learn the Fat Free Framework for PHP. http://fatfree.sourceforge.net/

It\'s is fairly simple to setup and I am running it on my machine usi

7条回答
  •  一整个雨季
    2020-12-18 03:06

    In your .htaccess you have 'index.php' it needs a slash ... '/index.php'

    # Enable rewrite engine and route requests to framework
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-l          
    RewriteCond %{REQUEST_FILENAME} !-f          
    RewriteCond %{REQUEST_FILENAME} !-d          
    RewriteRule .* /index.php [L,QSA]    
    

    otherwise when it tries to rewrite /about/ it will look for /about/index.php instead of just the root /index.php


    I just had another thought.. it 'is' possible that althought mod_rewrite is intalled there may be a quirk with the server causing it not to rewrite..

    If the global route below doesnt work you might want to test the rewrite

    RewriteRule ^/google http://www.google.com [L,NC];
    

    You could also try a global route for the directory

    F3::route('GET /about/*','about');
    

    but that means anythin under domain.com/about/ ...... anything ... will reroute to the about function...


    A note about mod_rewrite and FF

    As you said, FF is givikng you a 404 because it is expecting '/' instead of '/index.php'... However, it is the index.php which is expecting the difference..

    To demonstrate that, i believe you can duplicate your

    F3::route('GET /','home');
    

    as

    F3::route('GET /index.php','home');
    

    and the page should display...

    The reason for this is if you just go to the / directory (or /index.php) eitehr way apache servesx the index.php page....

    The mod_rewrite allows you to redirect the /about and have it redirect to the index.php.. So if your rewrite rule is not working then the redirect/rewrite does not happen and you will get a 404...

    As i mentioned above, test the mod_rewrite with the google rule.. then try to go to http://localhost:80/google if it does not redirect you to google then your rewrite engine is not working... (probably an issue with the windows configuration..)


    to enable mod_rewrite under windows: Open your http.conf Find this line:

    #LoadModule rewrite_module modules/mod_rewrite.so
    

    remove the comment mark (#) from the line... so you have: LoadModule rewrite_module modules/mod_rewrite.so Save the file and restart apache..

    Alternatly.. I think you can just say:

    LoadModule rewrite_module modules/mod_rewrite.so
    

    at the start of your htaccess file...

提交回复
热议问题