Re: [WebDNA] set HTTP-Status Code from webdna

This WebDNA talk-list message is from

2016


It keeps the original formatting.
numero = 112699
interpreted = N
texte = 282 --Apple-Mail=_CFCB72C0-865C-473B-A567-8DCF01ACAB2A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 blunt answer: I don=E2=80=99t. that=E2=80=99s the whole point of pretty URLS.=20 instead of example.com/blog.tpl?year=3D2012 = &month=3D04 my URL would be: example.com/blog/2012/04/ = A little [listwords words=3D[thisurl]&delimiters=3D/] gets me the = arguments which are fed into a series of rules in dispatch.tpl I=E2=80=99m very careful not to leak fieldnames/databases names/anything = that gives away the internal structure of my web engine thru a URL.=20 -Brian B. Burton > On Mar 29, 2016, at 5:20 AM, Noah Valley wrote: >=20 > Brian, >=20 > Thanks for your inputs. I've played around your solution and ours = solutions for the last few days. >=20 > One question came up: > How do you now deal with get variables? > When a user visits: domain.com/example?year=3D2012 = , the server directs the request = to domain.com/ dispatch.tpl = which shows the include to the url = =E2=80=9E/example=E2=80=9C but doesn=E2=80=99t get the year=3D2012. (at = least not from our server, a lighttpd) > How did you solve that problem? >=20 > Thanks > Noah >=20 >> Am 24.03.2016 um 18:47 schrieb Brian Burton >: >>=20 >> Noah,=20 >>=20 >> Great question, and I had to think and remember what the heck I = implemented (it=E2=80=99s been a while, it just works, lol)=20 >>=20 >> Here=E2=80=99s the magic line from my Apache site config: >> ErrorDocument 404 /dispatch.tpl >>=20 >> So any path that matches an actual file (image files, css, that = stuff) just works. >> All of my "pretty" URLs don't match any actual file, so they error = out to dispatch.tpl >> (my actual files that do the WebDNA work are named in a hard (near = impossible) to guess manner.) >>=20 >> Dispatch.tpl has hundreds of different rules, based on a stupidly = large variety of possible requests, but here=E2=80=99s a fake example: >>=20 >> [switch value=3D[thisurl]] >> [Case value=3D/dishwasher-parts] [text = multi=3Dt]pagefound=3Dt&usepage=3Dmfg-by-letter.inc&ProdCat=3D867 >> &pagetitle=3DPick Your Dishwasher Manufacturer[/text][/Case] >> [/switch] >>=20 >> at the end of dispatch.tpl: >>=20 >> [!] if you've gotten to this point and not matched a URL rule then = you needed the error page [/!] >> [showif [pagefound]=3Df] >> [appendfile file=3D^data/404.log][date] [time] [ipaddress] [thisurl] = [referrer][unurl]%0A[/unurl][/appendfile] >> [404soft] >> [/showif] >>=20 >> [showif [pagefound]=3Dt][include file=3D/[usepage]][/showif] >>=20 >>=20 >> So... no redirects, just clever use of include files.=20 >>=20 >>=20 >> -Brian B. Burton >>=20 >>> On Mar 24, 2016, at 11:41 AM, Noah Valley > wrote: >>>=20 >>> Brian, >>>=20 >>> Thanks for your answer! >>> I just dug in the talk@webdna-archives lookup for =E2=80=9Eredirect" = and stumbled over the same explanation from you from January=E2=80=A6 It = helps! Sorry for asking again... :-S >>>=20 >>> Another question now just came up in my head: How do you redirect to = files with your dispatch.tpl? >>> If someone needs the file domain.com/images/image.jpg = the server redirect to = domain.com/dispatch.tpl?url=3D/images/image.jp = or something, = right? how do you redirect that back to the file itself without getting = caught by the url-rewrite again? >>>=20 >>> Thanks >>> Noah >>>=20 >>>> Am 24.03.2016 um 17:28 schrieb Brian Burton >: >>>>=20 >>>> Noah,=20 >>>>=20 >>>> Similar to you, and wanting to use pretty URLs I built something = similar, but did it a different way. >>>> _All_ page requests are caught by a url-rewrite rule and get sent = to dispatch.tpl >>>> Dispatch.tpl has hundreds of rules that decide what page to show, = and uses includes to do it.=20 >>>> (this keeps everything in-house to webdna so i don=E2=80=99t have = to go mucking about in webdna here, and apache there, and linux = somewhere else, and etc=E2=80=A6)=20 >>>>=20 >>>> Three special circumstances came up that needed special code to = send out proper HTTP status codes: >>>>=20 >>>> >>>> [function name=3D301public] >>>> [text]eol=3D[unurl]%0D%0A[/unurl][/text] >>>> [returnraw]HTTP/1.1 301 Moved Permanently[eol]Location: = http://www.example.com[link][eol][eol][/returnraw] = >>>> [/function] >>>>=20 >>>> >>>> [function name=3D404hard] >>>> [text]eol=3D[unurl]%0D%0A[/unurl][/text] >>>> [returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: text/html[eol][eol][eol][eol]

404 = Not Found

[eol]The page that you have requested ([thisurl]) could = not be found.[eol][eol][/returnraw] >>>> [/function] >>>>=20 >>>> >>>> [function name=3D404soft] >>>> [text]eol=3D[unurl]%0D%0A[/unurl][/text] >>>> [returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: text/html[eol][eol][include = file=3D/404pretty.tpl][/returnraw] >>>> [/function] >>>>=20 >>>> Hope this helps >>>> -Brian B. Burton >>>>=20 >>>>=20 >>>>> On Mar 24, 2016, at 10:53 AM, Noah Valley > wrote: >>>>>=20 >>>>> Hi everybody, >>>>>=20 >>>>> The Question First: Is it possible to set the HTTP-Status Codes = with webdna? >>>>>=20 >>>>> Explanation why we need to do this: >>>>> I=E2=80=99ve been working with webdna for 3 years now but our our = business is on webdna since the 90ies; using it for a web-cms and custom = web-solutions. We now host about 150 websites on lighttpd. >>>>> We newly started using "url-rewrite" so we can have custom urls = for our websites. It directs calls from domain.com/cms/something = to domain.com/cms.dna?url=3Dsomething = .=20 >>>>> Example: Visitor goes to domain.com/cms/aboutus = and it shows domain.com/ = cms.dna = ?url=3Daboutus -> webdna = finds =E2=80=9Eaboutus" in DB and shows correct site >>>>> Problem: Visitor goes to domain.com/cms/somethingwrong = and it shows domain.com/ = cms.dna = ?url=3Dsomethingwrong -> = webdna does not find somethingwrong in DB and shows an error-page but = the HTTP status remains 200! >>>>>=20 >>>>> Is it possible to set the HTTP-Status Code with webdna? In this = case to 404 in other cases to something else. Or how would you solve = that problem? >>>>>=20 >>>>> Thanks! >>>>>=20 >>>>> Noah Valley >>>>> mac&web gmbh >>>>> S=C3=A4ntistrasse 13 >>>>> 8200 schaffhausen >>>>> switzerland >>>>>=20 >>>>> Tel +41 52 620 30 60 >>>>> Fax +41 52 620 30 61 >>>>> valley@mac-web.ch >>>>> www.mac-web.ch >>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list . = To unsubscribe, E-mail to: archives: = http://mail.webdna.us/list/talk@webdna.us = Bug Reporting: = support@webdna.us >>>=20 >>=20 >=20 --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us --Apple-Mail=_CFCB72C0-865C-473B-A567-8DCF01ACAB2A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 blunt answer: I don=E2=80=99t.
that=E2=80=99s = the whole point of pretty URLS. 
instead of example.com/blog.tpl?year=3D2012&month=3D04
my URL would be: example.com/blog/2012/04/

A little [listwords = words=3D[thisurl]&delimiters=3D/] gets me the arguments which are = fed into a series of rules in dispatch.tpl

I=E2=80=99m very careful not to leak = fieldnames/databases names/anything that gives away the internal = structure of my web engine thru a URL. 

-Brian B. Burton

On Mar 29, 2016, at 5:20 AM, = Noah Valley <valley@mac-web.ch> wrote:

Brian,

Thanks for your inputs. = I've played around your solution and ours solutions for the last few = days.

One = question came up:
How do you now = deal with get variables?
When a user visits: domain.com/example?year=3D2012, the server directs the = request to domain.com/dispatch.tpl which shows the include to the url = =E2=80=9E/example=E2=80=9C but doesn=E2=80=99t get the year=3D2012. (at = least not from our server, a lighttpd)
How did you = solve that problem?

Thanks
Noah

Am 24.03.2016 um 18:47 schrieb Brian Burton <brian@burtons.com>:

Noah, 

Great question, and I = had to think and remember what the heck I implemented (it=E2=80=99s been = a while, it just works, lol) 

Here=E2=80=99s the magic line from my = Apache site config:
ErrorDocument = 404 /dispatch.tpl

So any path that matches an actual file (image files, css, = that stuff) just works.
All of my "pretty" URLs = don't match any actual file, so they error out to dispatch.tpl
(my actual files that do the WebDNA work are named in a hard = (near impossible) to guess manner.)

Dispatch.tpl has hundreds of different = rules, based on a stupidly large variety of possible requests, but = here=E2=80=99s a fake example:

[switch = value=3D[thisurl]]
[Case = value=3D/dishwasher-parts] [text = multi=3Dt]pagefound=3Dt&usepage=3Dmfg-by-letter.inc&ProdCat=3D867<= /div>
&pagetitle=3DPick Your = Dishwasher Manufacturer[/text][/Case]
[/switch]

at the end of dispatch.tpl:

[!] if you've gotten to = this point and not matched a URL rule then you needed the error page = [/!]
[showif [pagefound]=3Df]
[appendfile file=3D^data/404.log][date] [time] [ipaddress] = [thisurl] [referrer][unurl]%0A[/unurl][/appendfile]
[404soft]
[/showif]

[showif = [pagefound]=3Dt][include file=3D/[usepage]][/showif]


So... no redirects, just clever use of include = files. 

-Brian B. Burton

On Mar 24, 2016, at 11:41 AM, Noah Valley = <valley@mac-web.ch> wrote:

Brian,

Thanks for = your answer!
I just dug in the talk@webdna-archives = lookup for =E2=80=9Eredirect" and stumbled over the same explanation = from you from January=E2=80=A6 It helps! Sorry for asking again... = :-S

Another question = now just came up in my head: How do you redirect to files with your = dispatch.tpl?
If someone needs the file domain.com/images/image.jpg the server redirect to domain.com/dispatch.tpl?url=3D/images/image.jp or = something, right? how do you redirect that back to the file itself = without getting caught by the url-rewrite again?

Thanks
Noah

Am = 24.03.2016 um 17:28 schrieb Brian Burton <brian@burtons.com>:

Noah, 

Similar to you, and = wanting to use pretty URLs I built something similar, but did it a = different way.
_All_ page requests are caught by a = url-rewrite rule and get sent to dispatch.tpl
Dispatch.tpl has hundreds of rules that decide what page to = show, and uses includes to do it. 
(this keeps = everything in-house to webdna so i don=E2=80=99t have to go mucking = about in webdna here, and apache there, and linux somewhere else, and = etc=E2=80=A6) 

Three special circumstances came up that needed special code = to send out proper HTTP status codes:

<!=E2=80=94 for page URLS that have = permanently moved (webdna sends out a 302 temporarily moved code on a = redirect) =E2=80=94>
[function = name=3D301public]
[text]eol=3D[unurl]%0D%0A[/unurl][/text]
[returnraw]HTTP/1.1 301 Moved Permanently[eol]Location: http://www.example.com[link][eol][eol][/returnraw]
[/function]

<!=E2=80=94 I send this to non google/bing/yahoo bots and = other attempting to crawl/copy the entire site=E2=80=94>
[function name=3D404hard]
[text]eol=3D[unurl]%0D%0A[/unurl][/text]
[returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: = text/html[eol][eol]<html>[eol]<body>[eol]<h1>404 Not = Found</h1>[eol]The page that you have requested ([thisurl]) could = not be found.[eol]</body>[eol]</html>[/returnraw]
[/function]

<!=E2=80=94 and finally a pretty 404 page for humans = =E2=80=94>
[function name=3D404soft]
[text]eol=3D[unurl]%0D%0A[/unurl][/text]
[returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: text/html[eol][eol][include = file=3D/404pretty.tpl][/returnraw]
[/function]

Hope this helps
-Brian B. Burton


On Mar 24, 2016, at 10:53 AM, Noah Valley = <valley@mac-web.ch> wrote:

Hi = everybody,

The = Question First: Is it possible to set the HTTP-Status Codes with = webdna?

Explanation why we need to do this:
I=E2=80= =99ve been working with webdna for 3 years now but our our business is = on webdna since the 90ies; using it for a web-cms and custom = web-solutions. We now host about 150 websites on lighttpd.
We newly started using "url-rewrite" so we can have custom = urls for our websites. It directs calls from domain.com/cms/something to domain.com/cms.dna?url=3Dsomething
Example: Visitor goes to domain.com/cms/aboutus and it shows domain.com/cms.dna?url=3Daboutus -> webdna finds =E2=80=9Eabou= tus" in DB and shows correct site
Problem: Visitor = goes to domain.com/cms/somethingwrong and it shows domain.com/cms.dna?url=3Dsomethingwrong -> webdna does = not find somethingwrong in DB and shows an error-page but the HTTP = status remains 200!

Is it possible to set the HTTP-Status Code with webdna? In = this case to 404 in other cases to something else. Or how would you = solve that problem?

Thanks!

Noah Valley
mac&web = gmbh
S=C3=A4ntistrasse 13
8200 = schaffhausen
switzerland

Tel = +41 52 620 30 60
Fax +41 52 620 30 61
valley@mac-web.ch
www.mac-web.ch

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us





= --Apple-Mail=_CFCB72C0-865C-473B-A567-8DCF01ACAB2A-- . Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] set HTTP-Status Code from webdna (Brian Burton 2016)
  2. Re: [WebDNA] set HTTP-Status Code from webdna (Noah Valley 2016)
  3. Re: [BULK] Re: [WebDNA] set HTTP-Status Code from webdna (Tom Duke 2016)
  4. Re: [BULK] Re: [WebDNA] set HTTP-Status Code from webdna (Brian Burton 2016)
  5. Re: [BULK] Re: [WebDNA] set HTTP-Status Code from webdna (christophe.billiottet@webdna.us 2016)
  6. Re: [WebDNA] set HTTP-Status Code from webdna (Brian Burton 2016)
  7. [BULK] Re: [WebDNA] set HTTP-Status Code from webdna (Brian Burton 2016)
  8. Re: [WebDNA] set HTTP-Status Code from webdna (Jym Duane 2016)
  9. Re: [WebDNA] set HTTP-Status Code from webdna (Noah Valley 2016)
  10. Re: [WebDNA] set HTTP-Status Code from webdna (Brian Burton 2016)
  11. [WebDNA] set HTTP-Status Code from webdna (Noah Valley 2016)
282 --Apple-Mail=_CFCB72C0-865C-473B-A567-8DCF01ACAB2A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 blunt answer: I don=E2=80=99t. that=E2=80=99s the whole point of pretty URLS.=20 instead of example.com/blog.tpl?year=3D2012 = &month=3D04 my URL would be: example.com/blog/2012/04/ = A little [listwords words=3D[thisurl]&delimiters=3D/] gets me the = arguments which are fed into a series of rules in dispatch.tpl I=E2=80=99m very careful not to leak fieldnames/databases names/anything = that gives away the internal structure of my web engine thru a URL.=20 -Brian B. Burton > On Mar 29, 2016, at 5:20 AM, Noah Valley wrote: >=20 > Brian, >=20 > Thanks for your inputs. I've played around your solution and ours = solutions for the last few days. >=20 > One question came up: > How do you now deal with get variables? > When a user visits: domain.com/example?year=3D2012 = , the server directs the request = to domain.com/ dispatch.tpl = which shows the include to the url = =E2=80=9E/example=E2=80=9C but doesn=E2=80=99t get the year=3D2012. (at = least not from our server, a lighttpd) > How did you solve that problem? >=20 > Thanks > Noah >=20 >> Am 24.03.2016 um 18:47 schrieb Brian Burton >: >>=20 >> Noah,=20 >>=20 >> Great question, and I had to think and remember what the heck I = implemented (it=E2=80=99s been a while, it just works, lol)=20 >>=20 >> Here=E2=80=99s the magic line from my Apache site config: >> ErrorDocument 404 /dispatch.tpl >>=20 >> So any path that matches an actual file (image files, css, that = stuff) just works. >> All of my "pretty" URLs don't match any actual file, so they error = out to dispatch.tpl >> (my actual files that do the WebDNA work are named in a hard (near = impossible) to guess manner.) >>=20 >> Dispatch.tpl has hundreds of different rules, based on a stupidly = large variety of possible requests, but here=E2=80=99s a fake example: >>=20 >> [switch value=3D[thisurl]] >> [Case value=3D/dishwasher-parts] [text = multi=3Dt]pagefound=3Dt&usepage=3Dmfg-by-letter.inc&ProdCat=3D867 >> &pagetitle=3DPick Your Dishwasher Manufacturer[/text][/Case] >> [/switch] >>=20 >> at the end of dispatch.tpl: >>=20 >> [!] if you've gotten to this point and not matched a URL rule then = you needed the error page [/!] >> [showif [pagefound]=3Df] >> [appendfile file=3D^data/404.log][date] [time] [ipaddress] [thisurl] = [referrer][unurl]%0A[/unurl][/appendfile] >> [404soft] >> [/showif] >>=20 >> [showif [pagefound]=3Dt][include file=3D/[usepage]][/showif] >>=20 >>=20 >> So... no redirects, just clever use of include files.=20 >>=20 >>=20 >> -Brian B. Burton >>=20 >>> On Mar 24, 2016, at 11:41 AM, Noah Valley > wrote: >>>=20 >>> Brian, >>>=20 >>> Thanks for your answer! >>> I just dug in the talk@webdna-archives lookup for =E2=80=9Eredirect" = and stumbled over the same explanation from you from January=E2=80=A6 It = helps! Sorry for asking again... :-S >>>=20 >>> Another question now just came up in my head: How do you redirect to = files with your dispatch.tpl? >>> If someone needs the file domain.com/images/image.jpg = the server redirect to = domain.com/dispatch.tpl?url=3D/images/image.jp = or something, = right? how do you redirect that back to the file itself without getting = caught by the url-rewrite again? >>>=20 >>> Thanks >>> Noah >>>=20 >>>> Am 24.03.2016 um 17:28 schrieb Brian Burton >: >>>>=20 >>>> Noah,=20 >>>>=20 >>>> Similar to you, and wanting to use pretty URLs I built something = similar, but did it a different way. >>>> _All_ page requests are caught by a url-rewrite rule and get sent = to dispatch.tpl >>>> Dispatch.tpl has hundreds of rules that decide what page to show, = and uses includes to do it.=20 >>>> (this keeps everything in-house to webdna so i don=E2=80=99t have = to go mucking about in webdna here, and apache there, and linux = somewhere else, and etc=E2=80=A6)=20 >>>>=20 >>>> Three special circumstances came up that needed special code to = send out proper HTTP status codes: >>>>=20 >>>> >>>> [function name=3D301public] >>>> [text]eol=3D[unurl]%0D%0A[/unurl][/text] >>>> [returnraw]HTTP/1.1 301 Moved Permanently[eol]Location: = http://www.example.com[link][eol][eol][/returnraw] = >>>> [/function] >>>>=20 >>>> >>>> [function name=3D404hard] >>>> [text]eol=3D[unurl]%0D%0A[/unurl][/text] >>>> [returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: text/html[eol][eol][eol][eol]

404 = Not Found

[eol]The page that you have requested ([thisurl]) could = not be found.[eol][eol][/returnraw] >>>> [/function] >>>>=20 >>>> >>>> [function name=3D404soft] >>>> [text]eol=3D[unurl]%0D%0A[/unurl][/text] >>>> [returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: text/html[eol][eol][include = file=3D/404pretty.tpl][/returnraw] >>>> [/function] >>>>=20 >>>> Hope this helps >>>> -Brian B. Burton >>>>=20 >>>>=20 >>>>> On Mar 24, 2016, at 10:53 AM, Noah Valley > wrote: >>>>>=20 >>>>> Hi everybody, >>>>>=20 >>>>> The Question First: Is it possible to set the HTTP-Status Codes = with webdna? >>>>>=20 >>>>> Explanation why we need to do this: >>>>> I=E2=80=99ve been working with webdna for 3 years now but our our = business is on webdna since the 90ies; using it for a web-cms and custom = web-solutions. We now host about 150 websites on lighttpd. >>>>> We newly started using "url-rewrite" so we can have custom urls = for our websites. It directs calls from domain.com/cms/something = to domain.com/cms.dna?url=3Dsomething = .=20 >>>>> Example: Visitor goes to domain.com/cms/aboutus = and it shows domain.com/ = cms.dna = ?url=3Daboutus -> webdna = finds =E2=80=9Eaboutus" in DB and shows correct site >>>>> Problem: Visitor goes to domain.com/cms/somethingwrong = and it shows domain.com/ = cms.dna = ?url=3Dsomethingwrong -> = webdna does not find somethingwrong in DB and shows an error-page but = the HTTP status remains 200! >>>>>=20 >>>>> Is it possible to set the HTTP-Status Code with webdna? In this = case to 404 in other cases to something else. Or how would you solve = that problem? >>>>>=20 >>>>> Thanks! >>>>>=20 >>>>> Noah Valley >>>>> mac&web gmbh >>>>> S=C3=A4ntistrasse 13 >>>>> 8200 schaffhausen >>>>> switzerland >>>>>=20 >>>>> Tel +41 52 620 30 60 >>>>> Fax +41 52 620 30 61 >>>>> valley@mac-web.ch >>>>> www.mac-web.ch >>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list . = To unsubscribe, E-mail to: archives: = http://mail.webdna.us/list/talk@webdna.us = Bug Reporting: = support@webdna.us >>>=20 >>=20 >=20 --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us --Apple-Mail=_CFCB72C0-865C-473B-A567-8DCF01ACAB2A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 blunt answer: I don=E2=80=99t.
that=E2=80=99s = the whole point of pretty URLS. 
instead of example.com/blog.tpl?year=3D2012&month=3D04
my URL would be: example.com/blog/2012/04/

A little [listwords = words=3D[thisurl]&delimiters=3D/] gets me the arguments which are = fed into a series of rules in dispatch.tpl

I=E2=80=99m very careful not to leak = fieldnames/databases names/anything that gives away the internal = structure of my web engine thru a URL. 

-Brian B. Burton

On Mar 29, 2016, at 5:20 AM, = Noah Valley <valley@mac-web.ch> wrote:

Brian,

Thanks for your inputs. = I've played around your solution and ours solutions for the last few = days.

One = question came up:
How do you now = deal with get variables?
When a user visits: domain.com/example?year=3D2012, the server directs the = request to domain.com/dispatch.tpl which shows the include to the url = =E2=80=9E/example=E2=80=9C but doesn=E2=80=99t get the year=3D2012. (at = least not from our server, a lighttpd)
How did you = solve that problem?

Thanks
Noah

Am 24.03.2016 um 18:47 schrieb Brian Burton <brian@burtons.com>:

Noah, 

Great question, and I = had to think and remember what the heck I implemented (it=E2=80=99s been = a while, it just works, lol) 

Here=E2=80=99s the magic line from my = Apache site config:
ErrorDocument = 404 /dispatch.tpl

So any path that matches an actual file (image files, css, = that stuff) just works.
All of my "pretty" URLs = don't match any actual file, so they error out to dispatch.tpl
(my actual files that do the WebDNA work are named in a hard = (near impossible) to guess manner.)

Dispatch.tpl has hundreds of different = rules, based on a stupidly large variety of possible requests, but = here=E2=80=99s a fake example:

[switch = value=3D[thisurl]]
[Case = value=3D/dishwasher-parts] [text = multi=3Dt]pagefound=3Dt&usepage=3Dmfg-by-letter.inc&ProdCat=3D867<= /div>
&pagetitle=3DPick Your = Dishwasher Manufacturer[/text][/Case]
[/switch]

at the end of dispatch.tpl:

[!] if you've gotten to = this point and not matched a URL rule then you needed the error page = [/!]
[showif [pagefound]=3Df]
[appendfile file=3D^data/404.log][date] [time] [ipaddress] = [thisurl] [referrer][unurl]%0A[/unurl][/appendfile]
[404soft]
[/showif]

[showif = [pagefound]=3Dt][include file=3D/[usepage]][/showif]


So... no redirects, just clever use of include = files. 

-Brian B. Burton

On Mar 24, 2016, at 11:41 AM, Noah Valley = <valley@mac-web.ch> wrote:

Brian,

Thanks for = your answer!
I just dug in the talk@webdna-archives = lookup for =E2=80=9Eredirect" and stumbled over the same explanation = from you from January=E2=80=A6 It helps! Sorry for asking again... = :-S

Another question = now just came up in my head: How do you redirect to files with your = dispatch.tpl?
If someone needs the file domain.com/images/image.jpg the server redirect to domain.com/dispatch.tpl?url=3D/images/image.jp or = something, right? how do you redirect that back to the file itself = without getting caught by the url-rewrite again?

Thanks
Noah

Am = 24.03.2016 um 17:28 schrieb Brian Burton <brian@burtons.com>:

Noah, 

Similar to you, and = wanting to use pretty URLs I built something similar, but did it a = different way.
_All_ page requests are caught by a = url-rewrite rule and get sent to dispatch.tpl
Dispatch.tpl has hundreds of rules that decide what page to = show, and uses includes to do it. 
(this keeps = everything in-house to webdna so i don=E2=80=99t have to go mucking = about in webdna here, and apache there, and linux somewhere else, and = etc=E2=80=A6) 

Three special circumstances came up that needed special code = to send out proper HTTP status codes:

<!=E2=80=94 for page URLS that have = permanently moved (webdna sends out a 302 temporarily moved code on a = redirect) =E2=80=94>
[function = name=3D301public]
[text]eol=3D[unurl]%0D%0A[/unurl][/text]
[returnraw]HTTP/1.1 301 Moved Permanently[eol]Location: http://www.example.com[link][eol][eol][/returnraw]
[/function]

<!=E2=80=94 I send this to non google/bing/yahoo bots and = other attempting to crawl/copy the entire site=E2=80=94>
[function name=3D404hard]
[text]eol=3D[unurl]%0D%0A[/unurl][/text]
[returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: = text/html[eol][eol]<html>[eol]<body>[eol]<h1>404 Not = Found</h1>[eol]The page that you have requested ([thisurl]) could = not be found.[eol]</body>[eol]</html>[/returnraw]
[/function]

<!=E2=80=94 and finally a pretty 404 page for humans = =E2=80=94>
[function name=3D404soft]
[text]eol=3D[unurl]%0D%0A[/unurl][/text]
[returnraw]HTTP/1.0 404 Not Found[eol]Status: 404 Not = Found[eol]Content-type: text/html[eol][eol][include = file=3D/404pretty.tpl][/returnraw]
[/function]

Hope this helps
-Brian B. Burton


On Mar 24, 2016, at 10:53 AM, Noah Valley = <valley@mac-web.ch> wrote:

Hi = everybody,

The = Question First: Is it possible to set the HTTP-Status Codes with = webdna?

Explanation why we need to do this:
I=E2=80= =99ve been working with webdna for 3 years now but our our business is = on webdna since the 90ies; using it for a web-cms and custom = web-solutions. We now host about 150 websites on lighttpd.
We newly started using "url-rewrite" so we can have custom = urls for our websites. It directs calls from domain.com/cms/something to domain.com/cms.dna?url=3Dsomething
Example: Visitor goes to domain.com/cms/aboutus and it shows domain.com/cms.dna?url=3Daboutus -> webdna finds =E2=80=9Eabou= tus" in DB and shows correct site
Problem: Visitor = goes to domain.com/cms/somethingwrong and it shows domain.com/cms.dna?url=3Dsomethingwrong -> webdna does = not find somethingwrong in DB and shows an error-page but the HTTP = status remains 200!

Is it possible to set the HTTP-Status Code with webdna? In = this case to 404 in other cases to something else. Or how would you = solve that problem?

Thanks!

Noah Valley
mac&web = gmbh
S=C3=A4ntistrasse 13
8200 = schaffhausen
switzerland

Tel = +41 52 620 30 60
Fax +41 52 620 30 61
valley@mac-web.ch
www.mac-web.ch

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us





= --Apple-Mail=_CFCB72C0-865C-473B-A567-8DCF01ACAB2A-- . Brian Burton

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

sorting by date Y2K mix up (2000) Auto-closing of databases (was DON'T use old cart file!) (1997) Re[2]: Hiding files/images. (2000) Search context not finding recent entries (1998) Dates (1998) Not really WebCat- (1997) Ooops-Serial Number for NT (1997) SendMail context not working on CentOS 4 (2007) A Global Variable (1997) I give up!! (1997) Help formatting search results w/ table (1997) Emailer [cart] file names (1997) Protecting webdelivery (1997) Multiple edits/replacementsd to db. Possible? (1997) [WebDNA] blogger (2009) Help name our technology! I found it (1997) [LOOKUP] (1997) Trouble with formula.db (1997) Frames and WebCat (1997) A Couple Photos from the SmithMicro Booth at MacWorld (2000)