dongmi1872 2011-09-16 18:40
浏览 27

对于使用php调用的页面使用.htaccess

I'm making a page as follows, There will be a menu for on the left. In the menu there will be links home, page1, page2, page3 and pageProtected. When I click on any page, this menu will remain unchanged. Only the content of the page on the right will change.

I made a file "left.php" and content of each page as "page1Content.php" etc.

When I click on page1, it takes me to page1.php, which includes left.php and page1Content.php.

Html code...
<?php include("left.php")?>
more html code...
<?php include("page1Content.php")?>

So in each file, only the second included file changes. All the html code are identical for all pages. But I have a protected page, which needs a login window. It is called "pageProtected.php". The thing is I want to keep this file in the main folder, but keep the content: "pageProtectedContent.php" in a folder where I put the .htaccess file.

However when I do this, it doesn't ask password. And when I put "pageProtected.php" in this folder, I have to change "left.php" that I include in this file. Then my purpose of keeping a unique "left.php" is not satisfied. What are my options?

Probably this is a very novice question, but I couldn't find a solution in the internet. Note: I don't want to use frames for the left menu.

  • 写回答

1条回答 默认 最新

  • dongyao1915 2011-09-16 18:46
    关注

    .htaccess files only prevent the files from being accessed in a web browser, PHP can include files in htaccess protected folders as if they weren't protected.

    I think what you need to do is have pageProtectedContent.php check for a cookie or use php sessions to facilitate login and authentication.

    If it is included and the user is not logged in, it will display a login form, if they are logged in, then it will display the protected content.

    The only other way to use .htaccess would be to put the protected pages in the protected folder, but you would then need to change your include statements to use ../left.php etc.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100