Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
trouble routing anything but the index file
  • I had to change webhost. the new configuration is similar to the one that was working before. except in the new server, i can only view the index page of the site. Any other page gives me a 404 error. ( not from fuel but from the server) this is what my .htaccess file looks like :
    <IfModule mod_rewrite.c>
        RewriteEngine on
    
        RewriteCond %&#123;REQUEST_FILENAME} !-f
        RewriteCond %&#123;REQUEST_FILENAME} !-d
    
       RewriteRule ^(.*)$ index.php?$1 [L]
    </IfModule>
    
    any suggestions would be greatly appreciated
    thanks u
  • In which folder is your .htaccess?
  • Michael Rüfenacht wrote on Wednesday 10th of August 2011:
    In which folder is your .htaccess?

    in the public folder
  • Try to move it a level up (same folder as your public is in) and add something like:
    <IfModule mod_rewrite.c>
     RewriteEngine on
    
     RewriteBase /public
    
     RewriteRule ^(/)?$ index.php/$1 [L]
    
     RewriteCond %&#123;REQUEST_FILENAME} !-f
     RewriteCond %&#123;REQUEST_FILENAME} !-d
    
     RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    
    If your not in the root folder, you have to change the RewriteBase accordingly.
  • I must admit i am no expert in .htaccess files. Anyway you could tell me how to adjust it to point to the public_html folder ? if it is set one level higher?
  • Ah sorry, my bad! How does your server document structure look like actually (similar to this one)? If it does you dont have to move the .htaccess.
    - fuel/
    - mail/
    - public_ftp/
    - public_html/
     -- index.php
     -- assets/
     -- .htaccess
    - www/
    

    So, could it be that your Hoster does not support mod_rewrite? You can test that by routing to another file (create yourtestfile.php in the public folder f.e. with a simple echo in it), and then change the .htaccess to:
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        RewriteRule ^(.*)$ yourtestfile.php/$1 [L]
    </IfModule>
    
    If mod_rewrite works, yourtestfile.php will be called instead the index.php
  • Hi there,
    thank you so much for the help so far.
    I tried the mod_rewrite test. I still get my index.php file to show still which tells me your suspicion is right and that the host does not support mod_rewrite.
    guess i am back to square one in my search for a decent webhost.
    thanks again for your help
  • You're welcome.
    You could try to comment out the (im not totally shure about that!): #RewriteBase / in the testfile.
  • I think I found the problem. Mod_rewrite requires a fully qualified domain name. while a server i tested before offered a temp url that looked like a fully qualified domain name. the latest company I tested, had only a regular test url with ~/username at the end which is not a fully qualified domain name.
    A localhost works also for mod_rewrite by the way.
    moral of the story, you need a Fully qualified domain name (one that looks like somehost.example.com. ) in order to run or test your site on a server
    I hope this saves someone time.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion