Status : 404 Not Found

18 posts by 2 authors in: Forums > CMS Builder
Last Post: January 7, 2008   (RSS)

By Djulia - December 28, 2007 - edited: December 28, 2007

Hi,

I seek to obtain a header 404 (Status : 404 Not Found ), if there is no recording (for multi page).

Currently CMS Builder gives the error message :

<?php if (empty($record)): ?>
No record found!<br/><br/>
<?php endif ?>

It is possible to use the function header of PHP ?

header("HTTP/1.0 404 Not Found");
or
header("Status: 404 Not Found");

Thank you for your assistance.

Djulia

Re: [Djulia] Status : 404 Not Found

By Djulia - December 29, 2007 - edited: December 29, 2007

Hi,

I found a beginning of answer.

<?php if (empty($record)): ?>
<?php
header("HTTP/1.1 404 Not Found");
header("Content-Type:text/html");
header("Connection: close");
exit();
?>
<?php endif ?>

1) But, it would be possible to use htaccess ?
ErrorDocument 404 /err.php

2) Now, I would like to correct some problems.
I have a recording with value 2, and I use the option useSeoUrls.

URL == demoPage.php/Page_1-2 (recording 2)

It is correct.
[/#ff0000]
demoPage.php/Page_1-24 == give 404 (with the use of the code <?php header 404... )

These URLs do not give an error 404.
[/#ff0000]
demoPage.php/Page_1-2abc == give a recording (the value of orderBy : ASC or DESC)
demoPage.php/Page_1abc-2 == give a recording (recording 2)
demoPage.php/Page_10123-2 == give a recording (recording 2)
demoPage.php/ == give a recording (the value of orderBy : ASC or DESC)
demoPage.php == give a recording (the value of orderBy : ASC or DESC)

There would be a solution for correcting these problems ?

Thank you for your answer.

Djulia

Re: [Djulia] Status : 404 Not Found

By Dave - December 31, 2007

For the 404 page, if you just wanted to show your regular 404 page that you use for the rest of your site, you could probably print it after the headers with something like:
print file_get_contents("/path/to/your/404/file.html")

You can read more about that PHP function here: http://php.net/function.file-get-contents

If you wanted to have it do something advanced like add something to your error log, or interact with your apache web server, or other things todo with .htaccess config files, I'd bet that's possible with PHP, but I'm not sure exactly how. You'd have to research it.

For the links, it seems like you have some extra stuff in there. I don't think you want the "page_1" part? They should be in this format:

demoPage.php/(contents_of_viewerUrl_field)-(record_number)
like this: demoPage.php/my_article_or_page_name-2

Is that how you want it? Is your viewer generating those other urls or is there a different format that you want to use?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Status : 404 Not Found

By Djulia - January 2, 2008 - edited: January 2, 2008

Hi Dave,

Thank you for your answer.

1) In fact, I want to avoid a duplicate content.

For example:

demoPage.php
demoPage.php/
demoPage.php/Home-1

They are different URLs, but for the same page.

Here is the solution which I found for the moment. In a file htaccess:

RewriteRule ^(.*)demoPage\.php$ /xxx/demoPage.php/? [R=301,L]
Redirect permanent /xxx/demoPage.php/Home-1 ...mydomain.com/xxx/demoPage.php/

This redirects :

/xxx/demoPage.php
/xxx/demoPage.php/Home-1

towards /xxx/demoPage.php/

All is correct and that avoids a duplicate content.

2) Now, I want redirects :

demoPage.php/Page_1-2abc[/#ff0000]
demoPage.php/Page_1-2/[/#ff0000]

towards demoPage.php/Page_1-2
or on a page 404.

I did not find the solution with the use of htaccess.
My server always gives an error 500.

Also, my question :

It is perhaps possible to prohibit the use of the letters (abc...) for : -(record_number) ?

Currently, if a visitor enter /xxx/Page_1-2abc[/#ff0000] for example, the CMS Builder gives a recording.
It would be better to give an error 404 or redirects the user on : Page_1-2.

Thank you for your assistance.

Djulia

P.S. : This post is the continuation of
http://www.interactivetools.com/forum/gforum.cgi?post=58520#58520

Re: [Djulia] Status : 404 Not Found

By Dave - January 3, 2008

>It is perhaps possible to prohibit the use of the letters (abc...) for : -(record_number) ?

It is. In fact, we can have the urls look like just about anything you like. The hardest part is usually figuring our exactly how you want it to work.

What if we had something like this:

demoPage.php (shows Home)
demoPage.php/home/
demoPage.php/about_us/
demoPage.php/mypage1/
demoPage.php/mypage2/
demoPage.php/contact/

(Or whatever your page names were?) Then anything else would show the contents of the 404 page?

I think we're releasing a new version tomorrow with some of your feature requests that should make that a lot easier. I could create a sample viewer that worked like that if you like?

Alternatively, I could tell you how to have it only accept certain urls with your current system.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Status : 404 Not Found

By Djulia - January 3, 2008

Thank you for your answer.


(Or whatever your page names were?) Then anything else would show the contents of the 404 page?

I think we're releasing a new version tomorrow with some of your feature requests that should make that a lot easier. I could create a sample viewer that worked like that if you like ?


It would be perfect !

Djulia

Re: [Djulia] Status : 404 Not Found

By Dave - January 3, 2008 - edited: January 3, 2008

Ok, I've attached 'blog.php'. You may need to adjust some of the field names and the lib path at the top but it shows the menu and the content all with one file with the url format you specified.

If you specify an url it doesn't have, it will display the 404 page (specify the path in the code).

Note, I've added extra blog fields for "order" (which specifies page sort order), and "pageurl" (which specifies what is shown after url, such as "home").

If you upgrade to the latest version (being released today) you'll be able to set "pageurl" to be "required" and "unique" even if it's a pulldown list. As well, you'll be able to disable adding, removing, and set a max record limit for the table, and even set fields to be "adminOnly" so only admin users can update them.

If you do want to upgrade, you'll want to make a note of any custom changes you've made to your code. Backup first!

Hope that helps! Let me know if you have any questions. I think this one should do exactly what you want.
Dave Edis - Senior Developer
interactivetools.com
Attachments:

blog.php 3K

Re: [Dave] Status : 404 Not Found

By Djulia - January 4, 2008

Thank you for your assistance.

I have a problem with the menu and the variable pageLink.
In fact, it gives bad URL :

If I am on blog.php, I have the following Menu :

Menu == URL

Home == blog.php/Home/
Page1 == blog.php/Page1/
Page2 == blog.php/Page2/
Gallery == blog.php/Gallery/

But, if I am on page1.php:

Home == page1.php//Home/
Page1 == page1.php//Page1/
Page2 == page1.php//Page2/
Gallery == page1.php//Gallery/

And, if I am on page2.php :

Home == page2.php//Home/
Page1 == page2.php//Page1/
Page2 == page2.php//Page2/
Gallery == page2.php//Gallery/

(...)

You have an idea ?

Djulia

P.S. : Update 1.6 is perfect ! Thank you.

Re: [Dave] Status : 404 Not Found

By Djulia - January 4, 2008 - edited: January 4, 2008

Excuse me, I correctly did not explain.

In fact, the Menu should be identical on the 4 pages.

blog.php/(contents_of_viewerUrl_field)/

Home == blog.php/Home/
Page1 == blog.php/Page1/
Page2 == blog.php/Page2/
Gallery == blog.php/Gallery/

But currently with the code suggested, it is different on each page (the 4 pages), and the URLs has the value of :(contents_of_viewerUrl_field).php//(contents_of_viewerUrl_field)/

Home == page1.php//Home/
Page1 == page1.php//Page1/
Page2 == page1.php//Page2/
Gallery == page1.php//Gallery/

You have an idea ?

Thank,

Djulia