Status : 404 Not Found

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

By Dave - January 4, 2008

Ok, instead of:

(contents_of_viewerUrl_field).php//(contents_of_viewerUrl_field)/

Try this (changing filename and removing extra slash):

blog.php/(contents_of_viewerUrl_field)/

The code should generate links like that already. It might have got changed during integration. If you get stuck on it attach your viewer file and I'll have a look. It seems to be working on my end correctly. Let me know how it goes.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Status : 404 Not Found

By Djulia - January 4, 2008

I found a solution.

I modified the value of :

$pageLink = "{$_SERVER['PHP_SELF']}/{$menuRecord['pageurl']}/";
with
$pageLink = "/blog.php/{$menuRecord['pageurl']}/";

... and this functions it correctly. [:)]

2) I have a last adjustment.

I have the URL following :
http://www.xxx.com/blog.php/page_2/

It would be possible to redirect :

/blog.php/page_2 (without /[/#ff0000])
on :
blog.php/page_2/

Or, obtain an error 404 ?

It is a detail, but sometimes the sites make errors in the exchange of link (…)

Thank you Dave for your patience.

Julia

Re: [Dave] Status : 404 Not Found

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

Hi Dave,

Thank you, your code works marvelously. [:)]

I also noticed that blogPage or blogPage.php gives the same result.

/folder/blogPage[/#0080ff]/page1/
/folder/blogPage[/#0080ff].php[/#ff0000]/page1/

You think, that it is possible to obtain a result only for .../blogPage/...[/#0080ff] ?

Then, .../blogPage.php/... would give an error 404 ?

Thank you for your answer.

Julia

By Dave - January 6, 2008

You must have something setup on your server so "blogPage" works without the ".php". Usually it wouldn't without some extra changes.

Anyway, the script url is stored in $_SERVER["PHP_SELF"] so you can use the preg_match() function to check if there's a .php in the url.

$hasDotPHP = preg_match("/\.php/", $_SERVER['PHP_SELF']);

And then add that as "OR $hasDotPHP" to your 404 check:

$hasDotPHP = preg_match("/\.php/", $_SERVER['PHP_SELF']);
if (!$pageRecord || $pageNameSetAndNoSlash || $hasDotPHP) {

Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Status : 404 Not Found

By Djulia - January 6, 2008

Hi Dave,

But, you think, that one can use the two codes together ?

$urlEndsWithSlash = preg_match("|/$|", @$_SERVER["PATH_INFO"]);
if (!$pageRecord || !$urlEndsWithSlash) {


$hasDotPHP = preg_match("/\.php/", $_SERVER['PHP_SELF']);
if (!$pageRecord || $pageNameSetAndNoSlash || $hasDotPHP) {




I made several tests, but I do not manage to obtain a satisfactory result.

The idea, it is to obtain an error 404 for : /folder/blogPage.php[/#ff0000]/page/

and not for : /folder/blogPage/page/

But : /folder/blogPage/page
must also give an error 404.

Thank,

Julia

By Dave - January 6, 2008

I wasn't sure which code you were using, you just need to add "|| $hasDotPHP" to the end of the if() statement. If it's not working I'm not sure why but you could track it down by printing out some values like this:

PHP_SELF = '<?php echo $_SERVER['PHP_SELF']; ?>'
hasDotPHP = '<?php echo $hasDotPHP; ?>'


PHP_SELF should have the script url "/folder/blogPage.php/" and if it has ".php" in it then it should set $hasDotPHP. Then if you know it has ".php" you could display the 404. Checking for the .php shouldn't change how anything else is working.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Status : 404 Not Found

By Djulia - January 7, 2008

Thank you for your assistance.

Your suggestion enabled me to correct my problem.

In fact, my server does not guarantee the use of : ( $_SERVER['PHP_SELF'] ).

In my case, it gives "/page1/" for "/folder/blogPage.php/page1/"

But, it seems that the use of ( $_SERVER['SCRIPT_NAME'] ) also works.

Thank you, you are a very good teacher.

Thank,

Julia