Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
mod rewrite prob...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
boby-s



Joined: 10 Apr 2004
Posts: 222
Location: Samobor< >Zagreb

PostPosted: 18.10.2005 21:59    Post subject: mod rewrite prob... Add user to your forum ignore list Reply with quote

imam link

http://sajt.com/profil.php?id=123

i treba ga rewriteat u

http://sajt.com/profil/123/

to radim sa

Code:

RewriteRule ^profil/([0-9a-zA-Z-]+)/?$ profil.php?id=$1


ali on rewritea u

http://sajt.com/profil/123

( primjetite sadnji slash )

kako da dodam ovaj zadnji slash?
Back to top
View user's profile Send private message
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 18.10.2005 22:33    Post subject: Add user to your forum ignore list Reply with quote

molim? pa ne rewrita se URL sam, onako kako ga ti napises u adress bar on ce se prikazat... upisi oba i vidjet ces da rade.

dakle ne rewrita se profil.php?id=$1 u ^profil/([0-9a-zA-Z-]+)/?$ nego obrnuto. a ova sekvenca /? znaci da je svejedno postoji li zadnji slash ili ne.

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 18.10.2005 22:35    Post subject: Add user to your forum ignore list Reply with quote

Žao mi je što moram biti onaj koji će ti prvi unišitit snove, ali ti ne rewrajtaš "/profil.php?id=123" u "/profil/123/" nego obrnuto, ako razumiješ kako mod_rewrite radi. Dakle ako netko upiše u browser "/profil/123/" Apache će zapravo izvršiti "/profil.php?id=123" bez da korisnik toga bude svjestan.

Sad kad bolje razumiješ stvari možda možeš pobliže objasniti problem trailing slasha na ispravan način?

EDIT: Eto Nelči me rastura u brzini
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boby-s



Joined: 10 Apr 2004
Posts: 222
Location: Samobor< >Zagreb

PostPosted: 19.10.2005 16:14    Post subject: Add user to your forum ignore list Reply with quote

Quote:
Dakle ako netko upiše u browser "/profil/123/" Apache će zapravo izvršiti "/profil.php?id=123" bez da korisnik toga bude svjestan.


to sam mislio Wink

my bad.zbunilo me ovo.REwrite
učim mod rw tek pa... Embarassed
Quote:

a ova sekvenca /? znaci da je svejedno postoji li zadnji slash ili ne.


ali kad probam bez ? onda ne radi...

Code:
RewriteRule ^profil/([0-9a-zA-Z-]+)/$ profil.php?id=$1


ne radi

Code:

RewriteRule ^profil/([0-9a-zA-Z-]+)/?$ profil.php?id=$1


samo http://sajt.com/profil/1
Back to top
View user's profile Send private message
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 20.10.2005 09:26    Post subject: Add user to your forum ignore list Reply with quote

Ti biraš koćeš li forsirati trailing slash ili nećeš. Kad upišeš URL "/profil/123" trebalo bi ti raditi bez obzira koju od gornje dvije linije u htaccessu koristio

Ako ti ne radi problem je drugdje
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boby-s



Joined: 10 Apr 2004
Posts: 222
Location: Samobor< >Zagreb

PostPosted: 20.10.2005 16:31    Post subject: Add user to your forum ignore list Reply with quote

koji kod onda da ovo radi?

http://sajt.com/profil/1/
Back to top
View user's profile Send private message
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 20.10.2005 19:38    Post subject: Add user to your forum ignore list Reply with quote

Ispravka Embarassed
Kad upišeš URL "/profil/123/" (primijeti trailing slash) trebalo bi ti raditi bez obzira koju od gornje dvije linije u htaccessu koristio Smile kad sam u zadnjem postu napisao da bi ti bez trailing slasha radilo sa obje htaccess linije malo sam se zaletio, u stvarnosti bi ti radilo samo sa drugom (gdje je trailing slash opcija)

ma jednostavno napiši čaroliju da rješi sve tvoje probleme (koje iskreno ne kužim, ali eto):
Code:
RewriteRule ^profil/([0-9a-zA-Z-]+)$ profil/$1/ [R]
RewriteRule ^profil/([0-9a-zA-Z-]+)/$ profil.php?id=$1

ovo se inače zove forsiranje trailing slasha... probaj upisati bez
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bj__



Joined: 09 Nov 2004
Posts: 65
Location: Karlovac

PostPosted: 20.10.2005 23:59    Post subject: Add user to your forum ignore list Reply with quote

samo da priupitam, jel bi
Code:
RewriteRule ^([0-9a-zA-Z-]+)$ $1/ [R]

obavio forsiranje trailing slasha za bilo koji url (bez ogranicavanja na /profil/) ili bi to trebalo mozda malo drugacije izgledati?
Back to top
View user's profile Send private message Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 21.10.2005 12:17    Post subject: Add user to your forum ignore list Reply with quote

gornji rule bi forsirao trailing slash na svim url-ovima koji izgledaju kao "/abz34k" ili "/tinky-winky" ili "keko2000", ali ako imaš url "/foo/bar" gornji rule neće forsirati slash jer regexp ovo neće matchati zbog slasha u sredini

ovo bi trebalo forsirati slash na svim pathovima koji imaju koliko-toliko normalna imena
Code:
^([0-9a-zA-Z/_-]+[0-9a-zA-Z])$

ali nikad tako nešto nisam koristio jer je korisnost toga upitna Confused
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boby-s



Joined: 10 Apr 2004
Posts: 222
Location: Samobor< >Zagreb

PostPosted: 21.10.2005 21:23    Post subject: Add user to your forum ignore list Reply with quote

hvala ti Shocked

mislim da sam sad sve skužio, napokon Razz
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group