tsuby Posted June 26, 2013 Report Posted June 26, 2013 Am urmatoarea Rewrite Rule in htaccess: RewriteRule ^articles/([A-Za-z0-9-]+)/?$ view.php?article_name=$1 [NC,L] si linkul de genul care trebuie schimbathttp://localhost/view.php?article_name=bla-blaAveti idee ce ar putea fi gresit? [nu fiti rai, ca sunt abia la inceput] Quote
bubbles Posted June 26, 2013 Report Posted June 26, 2013 RewriteRule ^articles/([^/]*)/$ /view.php?article_name=$1 [L] Quote
tsuby Posted June 26, 2013 Author Report Posted June 26, 2013 Am incercat, nu merge. Oricum, nu prea vad logica in ceea ce ai scris tu.Eu vreau ca din http://localhost/view.php?article_name=bla-bla sa fie schimbat in http://localhost/articles/bla-bla Quote
bubbles Posted June 26, 2013 Report Posted June 26, 2013 Si eu ce am scris ? Mai jos ai exact cum vrei.RewriteRule ^articles/([^/]*)$ /view.php?article_name=$1 [L] Quote
coolbyte Posted June 26, 2013 Report Posted June 26, 2013 Vrei cand accesezi http://localhost/articles/bla-bla sa duca la http://localhost/view.php?article_name=bla-bla. Quote
tsuby Posted June 26, 2013 Author Report Posted June 26, 2013 (edited) Inseamna ca fac altceva gresit. Asta e .htaccess-ul meu. Chestiile comentate au venit, evident, cu instalarea serverului si din ce vad eu nu prea au cum sa interfereze.#------------------------------------------------------------------------------# Server root folder www .htaccess# This file provides server security limiting access to the localhost only.# Comment next four lines to deactivate. (Allows external access)#------------------------------------------------------------------------------Order Deny,AllowDeny from allAllow from 127.0.0.1Allow from ::1#------------------------------------------------------------------------------# To allow execution of cgi scripts in this directory uncomment next two lines.#------------------------------------------------------------------------------AddHandler cgi-script .pl .cgiOptions +ExecCGI +FollowSymLinks#------------------------------------------------------------------------------# Activate this section to use the Private Server Feature!# Defaults: Username - root; Password - root# Note AuthUserFile: File path is relative to server root# To lock server, uncomment the next 4 lines. (A name and password is required)#------------------------------------------------------------------------------#AuthName "Uniform Server - Server Access"#AuthType Basic#AuthUserFile ../../../htpasswd/www/.htpasswd#Require valid-user RewriteEngine OnRewriteRule ^articles/([^/]*)/$ /view.php?article_name=$1 [L] @coolByteVreau exact invers. Pentru ca am ceva de genul <a href="view.php?article_name=blabla"> </a> Si cand dau click pe linkul ala sa devina localhost/articles/blabla. Edited June 26, 2013 by tsuby Quote
bubbles Posted June 26, 2013 Report Posted June 26, 2013 @tsuby - tu nici macar nu intelegi ce vrei sa faci Tu trebuie sa transformi link-urile alea sub ce forma vrei tu.Iar conditia scrisa in .htaccess nu face altceva decat sa iti interpreteze tie altfel link-urile.Babeste spunand tu trebuie sa ai <a href="articles/bla-bla"> </a> Quote
tsuby Posted June 26, 2013 Author Report Posted June 26, 2013 Ok, poate nu am expus problema foarte clar.Eu afisez un articol la urmatoarea pagina: http://localhost/view.php?article_name=gigi-becali-arunca-cu-baniiSi vreau, din varii motive ca linkul ala sa fie afisat utilizatorului sub urmatoarea forma:http://localhost/articles/gigi-becali-arunca-cu-banii Quote
bubbles Posted June 26, 2013 Report Posted June 26, 2013 Ai incercat tu sa accesezi http://localhost/articles/gigi-becali-arunca-cu-banii avand conditia aia pusa in .htaccess si nu merge ?Ma repet : in .htaccess rescri link-uri pentru ca serverul sa ti le poata interpreta dupa conditia scrisa de tine. Quote
tsuby Posted June 26, 2013 Author Report Posted June 26, 2013 Linkul imi ramane sub formahttp://localhost/view.php?article_name=gigi-becali-arunca-cu-banii Quote
bubbles Posted June 26, 2013 Report Posted June 26, 2013 Daca vrei sa te ajut, da-mi un exemplu direct pe pagina unde lucrezi ... daca nu o fi localhostul tau. Quote
coolbyte Posted June 27, 2013 Report Posted June 27, 2013 IncearcaRewriteRule ^articles/(.+)\$ view.php?article_name=$1 Quote
tsuby Posted June 27, 2013 Author Report Posted June 27, 2013 Imi cer scuze, cand am citit despre link rewritingul asta, nu am citit cum trebuie si am inteles complet altceva(ceva in genul ca acei doi parametri ar fi invers). Am rezolvat pana la urma, multumesc tuturor si scuze de n00bism. Quote