News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Guests can't see index.php?

Started by anidea, August 25, 2019, 03:04:44 PM

Previous topic - Next topic

anidea

Hi, I was hoping someone might have an easy answer for this.  Our forum is mostly private, but I added an "index.php" page that describes the site, for people that are directed to the forum.  Apparently no one ever gets to see it, though, because if you're a guest, the only thing you see is the login page prompting you to make a username, or if you're a member, you go straight to the forum and have no need to go to the root page.

For some reason I don't recall this being always true, but it's true now, and I'd like to know how to change it (but now I'm so old I don't remember what I did before, or even if I did it right).  Is there some setting I need to use to make http://mysite.org/ default to http://mysite.org/index.php and also make it viewable to guests?

Thank you!

Illori

link to your forum and the page in question? without seeing it we can guess all day on how to fix it, if we can see it we may be able to tell you exactly how to fix it.

anidea

#2

GigaWatt

#3
I believe this has something to do with your hosting account and/or the .htaccess file. This file also holds directives about which files to show and which files should be hidden when viewing the forum's root (or any other directory) from the web (http). Download the .htaccess file from the root of the forum, open it up with a text editor and see if it holds a line like this in it.

DirectoryIndex index.html index.htm index.php

If it does, comment out the line (put a # symbol in front of it), upload the modified .htaccess file to the forum's root and see if it properly redirects users to the index.php page when you type in http://yourdomain.tld/ (i.e. load http://yourdomain.tld/index.php).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

anidea

Ah, this is starting to sound familiar.  So it's nothing to do with SMF permissions then?  I don't seem to have an .htaccess file at all, but I do recall having/making one in the past.

Sorry, I've had some brain injury issues in the past few, so some of this is fuzzy.  I really appreciate the help!

anidea

So I created an .htaccess file, but nothing changed.  A registered member can see the index.php file just fine when going to the main page, but a guest only gets the page that allows them to sign up, even if I type in  http://mysite.org/index.php

Could there still be permissions issues relating to guests?

Illori

how do you have it setup that if you go to http://cubaamor.org/ it shows your forum which is in http://www.cubaamor.org/smf/index.php ? how are you creating the index.php page you want shown? it is from SMF?

anidea

I did this so long ago lol

index.php is located in the root.  At the top of index.php (and a few other custom pages sitting in the root) is the following:

//Path to SSI.php
require("/home/public/smf/SSI.php");

//Page title. This will appear in the browser
$context['page_title_html_safe'] = 'CubaAmor.org';

//This is self explanatory
template_header();


GigaWatt

Hmmm... this is what I'm getting when I type in http://cubaamor.org.



As you can see, the Register button is right there.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Illori

since you dont allow guests to view anything, after you include SSI.php it will always prompt for log in.

you would have to add code to allow guests to view something other then the log in box.

anidea

Quote from: GigaWatt on August 25, 2019, 03:56:35 PM
Hmmm... this is what I'm getting when I type in http://cubaamor.org.


As you can see, the Register button is right there.

But I don't want the Register button, well I do want it, but I want people to see the main index page (http://cubaamor.org/index.php) which has a bunch of text describing what the site is about, above that.  Or below it, frankly, I'm not overly concerned with where, just that the stuff shows when non-registered guests to go the website the first time.

anidea

#11
Quote from: Illori on August 25, 2019, 04:07:35 PM
since you dont allow guests to view anything, after you include SSI.php it will always prompt for log in.

you would have to add code to allow guests to view something other then the log in box.

I guess I'm asking what code to add to allow guests to view something other than the login box? 

I want them to view the login box, plus the stuff on index.php, which is what I thought it was supposed to do, but doesn't.

I just wanted a page that looks like the forum but is outside of the forum and therefore visible to guests.

Is there no way to do that, then?

GigaWatt

Could you draw what you're trying to achieve... use screenshots and a simple image editor, like Paint :).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Sir Osis of Liver

If you want to keep the login window and just add additional content to the page, you can put it in function template_kick_guest() in Login.template.php.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

anidea

Quote from: Sir Osis of Liver on September 12, 2019, 06:33:39 PM
If you want to keep the login window and just add additional content to the page, you can put it in function template_kick_guest() in Login.template.php.

Sorry that I'm just getting back to this...it's been a loooong semester...but I think this is what I was looking for but maybe didn't know it, so THANK YOU.  Going to try it out over winter break.  First I need to recover from the flu.  :(

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

anidea

Yikes.  Maybe it's the flu (still have it) but I have no idea what I'm doing.

Sir Osis of Liver

Did this in 2013, don't remember it very well, but this is basically what you do -

Login.template.php



// Display homepage if guest access is disallowed
function template_kick_guest()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;

// This isn't that much... just like normal login but with a message at the top.
echo '
<div>
<div class="cat_bar">
<h3 class="catbg">&nbsp Welcome to Your Forum!</h3>
</div>';

// Show the message or default message.
echo '

<div style="height: 800px; margin: 30px 0px 10px 0px;">

>>> your html page content here <<<

</div>';


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

anidea

So I still wasn't able to get the above sample working (adding to the login page).  I appreciate that you shared it with me, so thank you very much for that :)

BUT...

I thought I'd try adding an extra board and put a post in it that was open to guests, and sort of use that as my landing/entry page.  It's kinda cumbersome, but seems to work.  In the meantime...

By opening the one post to guests, suddenly my landing page (index.php outside of the forum) became available to guests/non-forum viewers too!  So that problem is solved!  Yay!

Now my question is, am I opening a can of worms by having a forum post viewable by guests?  Privacy on this forum is super important, which is why it's protected in the first place.  I've already lost the battle of trying to prevent people from having multiple usernames (and therefore creating issues in the community), but now I'm kinda worried about someone using the public post as a way to hack in or something?  Am I just being over-protective?

Advertisement: