如何查找SocialEngine PHP中新创建页面的根路径?
Hey there! Let's walk through how to find your new page's root path in SocialEngine PHP and set up password protection for it—since you mentioned your base path is public_html/site/application, I'll tie everything to that context.
SocialEngine uses an MVC framework, so the "root path" depends on whether your page was built via the admin panel or custom-developed:
1. Pages Created via SocialEngine's Admin Panel
These static pages don't have a unique physical file path—all their content, settings, and routing are stored in SocialEngine's database. When visitors access the page (e.g., yoursite.com/page/your-custom-page), the request is routed to the core page controller at:public_html/site/application/modules/Core/controllers/PageController.php
If you need a file-system anchor, the core module handling all admin-created pages lives at public_html/site/application/modules/Core, but this is a shared directory for all such pages—not a unique path for your specific page.
2. Custom-Developed Pages (Custom Modules/Controllers)
If you built a custom page by adding a new module or controller, its physical files live in these locations:
- Controller logic:
public_html/site/application/modules/[YourModuleName]/controllers/[YourController].php - View templates:
public_html/site/application/modules/[YourModuleName]/views/scripts/[controller-name]/[action-name].phtml
Your site's web root (where all front-end requests enter) is public_html/site/public—this is where the main index.php entry point lives.
You have two solid options depending on your needs:
Option 1: Use SocialEngine's Built-In Permissions (Recommended for Admin-Created Pages)
SocialEngine's native permission system integrates seamlessly with the platform, so this is the best bet for pages made via the admin panel:
- Log into your SocialEngine Admin Panel
- Navigate to Manage > Pages and locate your target page
- Click the Edit button, then switch to the Permissions tab
- Set access to Only Members (to restrict to logged-in users) or create a custom user group to limit access to specific people
- Save your changes—unauthorized users will be redirected to the login page or see a permission-denied message
Option 2: Apache .htaccess Password Protection (For Custom Pages or Server-Level Restriction)
If you need server-level password protection (e.g., for a custom page URL), use this method:
- Create a .htpasswd file: Use the
htpasswdcommand-line tool or an online generator to create a password file. Store it outside your web root (e.g.,public_html/.htpasswd) to prevent public access. - Edit your site's .htaccess: Open
public_html/site/public/.htaccessand add rules targeting your page's URL. For example, if your page is atyoursite.com/page/protected-page:
Replace<FilesMatch "^page/protected-page$"> AuthType Basic AuthName "Restricted Content" AuthUserFile /home/your-username/public_html/.htpasswd Require valid-user </FilesMatch>^page/protected-page$with your actual page URL path, and updateAuthUserFileto match the full path of your .htpasswd file. - Save the .htaccess file, then test the page—visitors will now see a browser prompt for a username and password.
内容的提问来源于stack exchange,提问作者John Green

