1 daniel Jun 26, 2009 13:29
3 daniel Jun 30, 2009 07:47
Sadly this is not very helpful for me... is there any way using / modifying the existing b2evo code for my needs?
4 sam2kb Jun 30, 2009 08:18
Add this to your .htaccess file and see if it works :)
# Redirect anything that's not an existing directory or file to http://your_domain.com
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/$ http://your_domain.com
5 daniel Jul 01, 2009 23:25
Hmm, thanks for your try sam2kb, but sadly it does not work... I still get this 'Sorry, there is no post to display...' message...
6 sam2kb Jul 02, 2009 01:44
Daniel wrote:
Hmm, thanks for your try sam2kb, but sadly it does not work... I still get this 'Sorry, there is no post to display...' message...
The thing is when you get this message it means that the requested page exists. You probably get it when you click on empty category, right?
Can you post a link?
7 daniel Jul 02, 2009 07:23
Hm, I even get it, when I (would) use a URL link, that I corrected by hand seconds after posting... So, http://www.chaoszone.de/blog/webnews.php/2009/06/26/cd_rom_partition_von_usb_stick_loschen (not existing) was changed to http://www.chaoszone.de/blog/webnews.php/2009/06/26/cd_rom_partition_von_usb_stick_loeschen (working) - but of course even http://www.chaoszone.de/blog/webnews.php/2009/07/02/test (not existing) will show the error message... only in German, but I think this onle line starting with "sorry..." might be clear...
Kind Regards,
Daniel
P.S. Currently I have removed your proposal from the .htaccess file
8 sam2kb Jul 02, 2009 07:36
For now any not existing URL brings you to
http://www.chaoszone.de/blog/
Try
http://www.chaoszone.de/qwerty.png
http://www.chaoszone.de/aaa_bbb_ccc/
It's most likely because you haven't removed the .htaccess thing yet.
Anyway what you need is "redirect if no post found", because you already have "redirect if not a page or a directory".
It's kinda hard for me to describe what I mean with my English :(, I'll better give you another hack to try ;)
9 daniel Jul 02, 2009 07:45
I would be really glad... and you are right, I have a working .htaccess file entry for non existing files; but this is not working for mis-typed posting URLs or simply if no post can be found... (sorry I´m not an English native speaker as well)
Funny thing... it´s working for
http://www.chaoszone.de/blah
http://www.chaoszone.de/blog/blah
but not for
http://www.chaoszone.de/blog/webnews.php/blah
and
http://www.chaoszone.de/blog/webnews.php/2009/06/30/blah
returns with the b2evo message, no post found...
10 daniel Jul 02, 2009 07:52
...perhaps it´s easier to help me, if I show you, what I already have as .htaccess file:
In my root directory it´s only:
ErrorDocument 404 /index.php
And in my /blog/ directory (with all the b2evo stuff) there is a second .htaccess file with the following content:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^index\.php/webnews/?(.*)$ /blog/webnews.php/$1 [QSA,R,L]
RewriteRule ^index\.php/weblinks/?(.*)$ /blog/weblinks.php/$1 [QSA,R,L]
11 sam2kb Jul 02, 2009 18:06
Edit the following in your _main.php file. Not tested.
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
if( isset($MainList) && $MainList->result_num_rows == 0 )
{ // Redirect to blog home
header_redirect( $Blog->get('url') );
}
12 daniel Jul 02, 2009 20:26
Hey this works great! Thank you...
Only to play a little bit more with the code, how I would have to modify the "header_redirect( $Blog->get('url') )" to direct it to any page I want? I think about a error message page for let´s say 3 seconds and then redirecting automatically to index.php
Interesting to say, I have to put your code really nearly the top after "
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );" otherwise it´s not working properly...
Ah, and it redirects to the blog index page and not to index.php... but that would be tolerable... and changeable, if you would know the answer to my above question!
In general thank you very much!
Regards,
Daniel
13 sam2kb Jul 02, 2009 20:45
header_redirect( 'http://myurl.com' );
You can do "[url=http://www.google.com/search?q=meta+redirect]meta redirect[/url]" with delay, but this is not a good idea. You may want to display a message [u]after[/u] redirect which is way better, I think.
Something like this, not tested again ;)
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
if( isset($MainList) && $MainList->result_num_rows == 0 )
{ // Redirect to blog home
global $Messages, $Session, $ReqHost, $ReqURI;
$Messages->add( sprintf( 'You have been redirected from %s<br />The requested page was not found etc...', $ReqHost.$ReqURI ), 'note' );
$Session->set( 'Messages', $Messages );
header_redirect( $Blog->get('url') );
}
14 daniel Jul 04, 2009 15:57
That works perfectly! Thank you so much!
Altought this is somewhat easy to do, I think that this would let the search engines crazy...