sEnte Posted February 14, 2013 at 10:16 AM Report #495216 Posted February 14, 2013 at 10:16 AM Então é assim No ficheiro que está agora selecionado tenho isto <?php $url = $_GET['url']; echo $url; ?> Se na barra de endereço escrever http://127.0.1.1/mvc/blarg (se escrever index ou outra coisa qualquer mostra-se o que está escrito depois de mvc/) aparece-me na página "blarg" já que é o que estou a mandar fazer output Depois crio outro ficheiro em controllers/index.php e meto isto <?php class Index { function __construct(){ echo 'We are in index'; } } ?> tenho que adicionar no ficheiro index.php (o que está selecionado na imagem.) <?php $url = $_GET['url']; echo $url; require 'controllers/' . $url . '.php'; $controller = new $url; ?> se na barra de endereço escrever isto http://127.0.1.1/mvc/index deveria aparecer escrito "indexWe are in Index" mas o que tenho como output é só isto Citação Not Found The requested URL /mvc/index was not found on this server. Se criar em controllers o ficheiro help.php e meter lá isto <?php class Help{ function __construct(){ echo 'We are inside help'; } } ?> se for a http://127.0.1.1/mvc/help já funciona como deve ser ou seja aparece "helpWe are inside help". Ainda pensei que tivesse a mandar para o sitio errado o index mas não. "If It Ain't Broke, Break it and build something Cooler!" Unknown
HappyHippyHippo Posted February 14, 2013 at 10:30 AM Report #495219 Posted February 14, 2013 at 10:30 AM qual(quais) o(s) comando(s) de reescrita do pedido ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
sEnte Posted February 14, 2013 at 10:31 AM Author Report #495220 Posted February 14, 2013 at 10:31 AM (edited) o .htaccess é o seguinte RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] Edited February 14, 2013 at 10:31 AM by sEnte "If It Ain't Broke, Break it and build something Cooler!" Unknown
HappyHippyHippo Posted February 14, 2013 at 10:46 AM Report #495222 Posted February 14, 2013 at 10:46 AM http://www.bennadel.com/blog/2218-Negotiation-Discovered-File-s-Matching-Request-None-Could-Be-Negotiated.htm remove o MultiViews da configuração do teu site IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
sEnte Posted February 14, 2013 at 10:49 AM Author Report #495223 Posted February 14, 2013 at 10:49 AM (edited) juntando Options Indexes FollowSymLinks parece ter resolvido o problema. o meu .htaccess agora está assim RewriteEngine On Options Indexes FollowSymLinks RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] Obrigado. Edited February 14, 2013 at 10:50 AM by sEnte "If It Ain't Broke, Break it and build something Cooler!" Unknown
HappyHippyHippo Posted February 14, 2013 at 11:09 AM Report #495227 Posted February 14, 2013 at 11:09 AM o que fizeste não foi juntar, mas fazer um override das options removendo o MultiViews ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
sEnte Posted February 14, 2013 at 11:23 AM Author Report #495230 Posted February 14, 2013 at 11:23 AM fiquei na mesma lol percebo muito pouco de .htaccess, porque raramente o uso podes explicar melhor? "If It Ain't Broke, Break it and build something Cooler!" Unknown
HappyHippyHippo Posted February 14, 2013 at 11:26 AM Report #495232 Posted February 14, 2013 at 11:26 AM as configurações do site estarão no ficheiro : /etc/apache2/sites-available/default o que fizeste não foi mais do que sobrepor as definições que ai estão no parâmetro options IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
sEnte Posted February 14, 2013 at 11:28 AM Author Report #495234 Posted February 14, 2013 at 11:28 AM (edited) O mais imsples será ir à raiz certo? <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> O que convem remover daqui? Edited February 14, 2013 at 11:28 AM by sEnte "If It Ain't Broke, Break it and build something Cooler!" Unknown
HappyHippyHippo Posted February 14, 2013 at 11:29 AM Report #495236 Posted February 14, 2013 at 11:29 AM cuidado : sempre que alteras esse ficheiro deverás reiniciar o servidor, e verificar se não deu bronca !!! IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
sEnte Posted February 14, 2013 at 11:31 AM Author Report #495237 Posted February 14, 2013 at 11:31 AM eu não alterei nada. simplesmente limitei-me a copiar o conteudo "If It Ain't Broke, Break it and build something Cooler!" Unknown
yoda Posted February 14, 2013 at 03:25 PM Report #495267 Posted February 14, 2013 at 03:25 PM Como é que passas parâmetros nesse sistema? before you post, what have you tried? - http://filipematias.info sense, purpose, direction
sEnte Posted February 14, 2013 at 04:52 PM Author Report #495293 Posted February 14, 2013 at 04:52 PM Ainda me estou a introduzir a este sistema 🙂 tenho uma pasta controladores onde crio as classes e faço extends Controller depois noutra pasta tenho as libraries onde crio os controladores, depois noutra pasta views que é onde tenho o front-end "If It Ain't Broke, Break it and build something Cooler!" Unknown
yoda Posted February 14, 2013 at 08:13 PM Report #495318 Posted February 14, 2013 at 08:13 PM (edited) Estar a usar a localização dos ficheiros no uri não me parece a melhor ideia, e até vai um pouco contra o que o mod_rewrite tem de bom (ocultar a localização original dos ficheiros). Edited February 14, 2013 at 08:15 PM by yoda before you post, what have you tried? - http://filipematias.info sense, purpose, direction
sEnte Posted February 16, 2013 at 10:59 PM Author Report #495681 Posted February 16, 2013 at 10:59 PM @yoda Estou aberto a sugestões dos conhecedores disto 😛 eu ainda estou em fase de aprendizagem. @HappyHippyHippo o que meti num post anterior é o conteudo do ficheiro default em /etc/apache2/sites-available/ o que é que devo mudar então? "If It Ain't Broke, Break it and build something Cooler!" Unknown
HappyHippyHippo Posted February 16, 2013 at 11:10 PM Report #495686 Posted February 16, 2013 at 11:10 PM nada ... não está a funcionar ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
sEnte Posted February 16, 2013 at 11:55 PM Author Report #495705 Posted February 16, 2013 at 11:55 PM se meter Options Indexes FollowSymLinks sim, caso contrário não "If It Ain't Broke, Break it and build something Cooler!" Unknown
yoda Posted February 17, 2013 at 12:14 AM Report #495716 Posted February 17, 2013 at 12:14 AM Então mete 😄 before you post, what have you tried? - http://filipematias.info sense, purpose, direction
sEnte Posted February 17, 2013 at 02:16 AM Author Report #495749 Posted February 17, 2013 at 02:16 AM isso no htaccess já está lol "If It Ain't Broke, Break it and build something Cooler!" Unknown
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now