Preciso da ajuda dos experts.
Estou com dificuldade em colocar para funcionar o modo rewrite no sistema que estou desenvolvendo.
Utilizo o debian 7.0.
Segue alguns passos que já fiz e refiz:
Habilitar o modo rewrite no apache 2.2
a2enmod rewrite
No apache tenho as seguintes informações:
AccessFileName .htaccess
RewriteLog /var/log/apache2/rewrite.log
RewriteLogLevel 9
Ao reiniciar o apache e abrir o phpinfo() percebo que o mod rewrite foi habilitado.
As minhas paginas abrem todas assim:
http://192.168.0.104/index.php?p=inc_informativos
http://192.168.0.104/index.php?p=inc_wiki
http://192.168.0.104/index.php?p=inc_ativos
criei uma função para encurtar o link:
function carregaUrls($url){
$caminho = str_replace("_", "/", $url);
if(is_file($caminho.".php")):
include_once $caminho.".php";
else:
throw new Exception("Essa pagina não existe!");
endif;
E a chamo no index.php da forma abaixo:
<li><a href="?p=inc_informativos">Informativos</a></li><?php if(isset($_GET['p'])): try{ carregaUrls($_GET['p']); } catch (Exception $e){ echo $e->getMessage(); } else: include_once 'index.php'; endif; ?>
Segue arvore do site:
index.php inc -> informativos.php wiki.php ativos.php
.htaccess:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^informativos/?$ /index.php?p=inc_informativos [NC,L] RewriteRule ^wiki/?$ index.php?p=inc_wiki [NC,L] RewriteRule ^ativos/?$ /index.php?p=inc_ativos [NC,L]</IfModule>
Se clicar no link informativos ele abre da maneira que não desejo:
http://192.168.0.104/index.php?p=inc_informativos
Se acessar diretamente no navegador abre normalmente, porém sem a formatação do css:
http://192.168.0.104/informativos/
Aguem poderia me ajudar nesse caso???
Att
Olhando alguns tópicos como esse:
http://forum.imasters.com.br/topic/449772-resolvidourl-amigavel-nao-identificafunciona/
Deixei somente o rewriterule abaixo no .htaccess:
RewriteRule ^informativos/?$ ?p=inc_informativos
Quando acesso o site
http://192.168.0.104/
Ele abre sem ter o index.php no link, mas se clicar na home e depois no link informativos o link se transforma para:
http://192.168.0.104/index.php?p=inc_informativos
Agora se acessar o site novamente igual abaixo e clicar em informativos ele já muda:
http://192.168.0.104/
http://192.168.0.104/?p=inc_informativos
Se colar no navegador o link http://192.168.0.104/informativos ele abre normalmente, porém ele não redireciona automáticamente.
Att