Pergunta

htaccess will not redirect whatever I type to the index.php on my server. But it works perfectly on my local server (wamp).

This is the htaccess:

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

It's the most basic htaccess ....

If I go to the main url there is no problem and the page loads but if I type something like /inventaris/index it gives me a 404 page.

On the same server i have other websites using htaccess. One of them is a wordpress blog with permalinks so mod_rewrite is enabled.

Anyone has an idea why this won't work? My live server is running on Ubuntu.

Update: Loaded Modules
core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status

Foi útil?

Solução 3

After some debugging I found out that the .htaccess file wasn't doing anything. Not even a basic forward.

After some googling I update the virtual host setting AllowOverride None to AllowOverride All. Same thing for the default virtual host (just to be sure). And it seem to work now.

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

Explanation I found: You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it's okay to allow .htaccess files to over-ride previous directives.

Outras dicas

Make sure that +FollowSymLinks is set under Options, I would use

RewriteRule ^index\.php$ - [L]
RewriteRule ^ /index.php [L]

This also helps you to get PATH_INFO.

DirectoryIndex index.php

IndexIgnore */*
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [QSA,L]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top