kokin Posted August 14, 2012 at 12:52 PM Report Share #472222 Posted August 14, 2012 at 12:52 PM Boa tarde, estou com dificuldade em obter um link amigável com um id. Se alguém poder ajudar 😉 Exemplo do que já consigo fazer: index.php?mod=home /home Exemplo do que pretendo: index.php?mod=home&pagina=1 /home/pagina/1 Link to comment Share on other sites More sharing options...
yoda Posted August 14, 2012 at 01:03 PM Report Share #472223 Posted August 14, 2012 at 01:03 PM RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT] before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
kokin Posted August 14, 2012 at 01:14 PM Author Report Share #472224 Posted August 14, 2012 at 01:14 PM RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT] Devo fazer alguma coisa depois disso? Coloquei no htaccess isso e experimentei "/home/pagina/1" e não funcionou Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 14, 2012 at 01:28 PM Report Share #472225 Posted August 14, 2012 at 01:28 PM RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /[^/]+/[^/]+/ index.php?mod=$0&$1=$2 [PT] IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
kokin Posted August 14, 2012 at 03:39 PM Author Report Share #472260 Posted August 14, 2012 at 03:39 PM (edited) RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /[^/]+/[^/]+/ index.php?mod=$0&$1=$2 [PT] Coloquei dessa maneira mas esta a dar erro. 404 Not Found error Deve de me faltar colocar alguma coisa no htaccess Eu penso que seja algo parecido com isto só não sei como corrigir RewriteRule ^home\/?(.*)\/pagina\/?([0-9]+) index.php?mod=home&pagina=$1 Edited August 14, 2012 at 03:49 PM by kokin Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 14, 2012 at 03:58 PM Report Share #472264 Posted August 14, 2012 at 03:58 PM RewriteRule ^(.*)\/(.*)\/ index.php?mod=$0&$1=$2 // A A A // | | | // $0 $1 $2 (porque não tens o caracter terminador) IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
kokin Posted August 14, 2012 at 10:00 PM Author Report Share #472306 Posted August 14, 2012 at 10:00 PM (edited) Tento isso e experimento o /home/pagina/1 e nada. Tenho um servidor que contem o site total, dentro tenho uma pasta no servidor com outro site aparte e é nesse que necessito isso. Será por isso que esta a dar problemas? 1º site www.siteexample.com 2º site www.siteexample.com/segundosite ideia consiste em www.siteexample.com/segundosite/home/pagina/1 ou ideia consiste em www.siteexample.com/segundosite/pagina/1 "sem o home porque por si este mod já o defaut" No primeiro site tenho um htaccess e no que estou a trabalhar também tenho um. Isto é o que tinha feito o ultimo Rewrite representa o que necessito e até funciona só que não aparece a página toda com o design. Ou seja não esta a interpretar o index RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^index\/?(.*)$ index.php RewriteRule ^sobre\/?(.*)$ index.php?mod=sobre RewriteRule ^contacto\/?(.*)$ index.php?mod=contactar RewriteRule ^pagina\/?([0-9]+) index.php?mod=home&pagina=$1 Edited August 14, 2012 at 10:09 PM by kokin Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 14, 2012 at 10:17 PM Report Share #472313 Posted August 14, 2012 at 10:17 PM testado e a funcionar RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/(.*) index.php?mod=$1&$2=$3 [PT] caso o site se encontra dentro de uma subpasta terás de alterar a entrada "RewriteBase" no caso acima descrito seria RewriteEngine On RewriteBase /segundosite/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/(.*) index.php?mod=$1&$2=$3 [PT] IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
kokin Posted August 14, 2012 at 10:29 PM Author Report Share #472322 Posted August 14, 2012 at 10:29 PM (edited) testado e a funcionar RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/(.*) index.php?mod=$1&$2=$3 [PT] caso o site se encontra dentro de uma subpasta terás de alterar a entrada "RewriteBase" no caso acima descrito seria RewriteEngine On RewriteBase /segundosite/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/(.*) index.php?mod=$1&$2=$3 [PT] Experimentei qualquer um dos dois, no htacess do segundo site. A mensagem é sempre a mesma. "The requested URL /videoclub/home was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." Edited August 14, 2012 at 10:29 PM by kokin Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 14, 2012 at 10:31 PM Report Share #472325 Posted August 14, 2012 at 10:31 PM o exemplo é para /videoclub/home/1 e não /videoclub/home IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
kokin Posted August 14, 2012 at 11:11 PM Author Report Share #472331 Posted August 14, 2012 at 11:11 PM (edited) Este código tive de retirar o (RewriteBase /) se meto nem funciona. O problema é que a página não fica estruturada somente interpretou a estrutura mas sem o css etc. Conseguiu intrepretar o mysql da página pretendida. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/(.*) index.php?mod=$1&$2=$3 [PT] só funciona com este link http://site.com/videoclub/home/pagina/1 Como tu explicaste não vai lá. Ta difícil 😛 Edited August 14, 2012 at 11:13 PM by kokin Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 14, 2012 at 11:14 PM Report Share #472332 Posted August 14, 2012 at 11:14 PM só funciona com este link http://site.com/videoclub/home/pagina/1 sim ... foi isso que pediste !!! www.siteexample.com/segundosite/home/pagina/1 IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
kokin Posted August 14, 2012 at 11:19 PM Author Report Share #472333 Posted August 14, 2012 at 11:19 PM (edited) sim ... foi isso que pediste !!! Mas porquê que não mostra o design da página ou seja porquê que ele não interpreta o css imagens etc do index? O que te deste ao trabalho de fazer já eu conseguia com isto RewriteRule ^pagina\/?([0-9]+) index.php?mod=home&pagina=$1 . Não percebo o porque ambos os exemplos estão a interpretar da mesma forma. Se utilizo a maneira antiga ele da correctamente index.php?pagina=2 ou index.php?mod=home&pagina=2 Edited August 14, 2012 at 11:20 PM by kokin Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 14, 2012 at 11:26 PM Report Share #472334 Posted August 14, 2012 at 11:26 PM a razão porque não esta a redirecionar corretamente pode ser por muitas razões faz post do url para se poder ver o que está a acontecer IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
kokin Posted August 15, 2012 at 12:51 AM Author Report Share #472338 Posted August 15, 2012 at 12:51 AM Muito obrigado happyhippyhippo pela dedicação, desculpa lá o trabalhão que te dei para me resolveres isto e me tirares as duvidas. 😉 Link to comment Share on other sites More sharing options...
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