HTACCESS规则正在与会话变量混乱

发布于 2025-02-13 17:30:28 字数 1129 浏览 0 评论 0原文

我对会话变量有问题。该网站目前托管在000webhost上。下面是我的htaccess文件在“ public_html”文件夹\ public_html \ .htaccess的根源中,

php_flag output_buffering on

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

这些会话存储在public_html级别的“ tmp”文件夹中\ code> \ tmp

i'''''''''''''' m在public_html文件夹中的index.php中使用以下代码\ public_html \ index.php要管理fetch api cors

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: *");
......
$urlpath = explode("/",rawurldecode($_SERVER['REQUEST_URI']));

$ urlPath varible将定义哪个页面将加载。我正在从资产文件夹和PHP页面中提供静态资产(ex:ex:platform1platform2),所有这些文件都在将级别保存为上述htaccess文件\ public_html \ Assets& \ public_html \ Platform1

Platform1文件夹创建和存储会话变量,以便可以通过多个页面访问它们。

现在的问题是,如果提供了HTACCESS规则,则不会存储会话变量。如果我删除重写规则,则会变量可完美。

我不擅长PHP功能,尤其是HTACCESS重写规则。一种非理想的方法是在每个页面加载上生成所有会话变量,以增加页面加载时间,因此我想将其保留为最后的度假胜地。

I'm having an issue with session variables. The site is currently hosted on 000webhost. Below is my htaccess file inside the root of "public_html" folder \public_html\.htaccess

php_flag output_buffering on

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

The sessions are being stored in "tmp" folder at the public_html level \tmp

I'm using the below code in the index.php inside public_html folder \public_html\index.php to manage a fetch API CORS

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: *");
......
$urlpath = explode("/",rawurldecode($_SERVER['REQUEST_URI']));

The $urlpath variable will define what page will load. I'm serving static assets from assets folder and PHP pages from different folder (ex: platform1,platform2) and all of them are at the save level as the above htaccess file \public_html\assets & \public_html\platform1

The PHP files inside the platform1 folder create and store session variables so they can be accessed across multiple pages.

The problem now is if the htaccess rules are provided, session variables are not stored. If I remove the rewrite rules, session variables work perfectly.

I'm not adept at PHP functions, especially with the htaccess rewrite rules. One non-ideal way is to generate all the session variables on every page load which increases the page load times and such I'd like to keep this as a last resort.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文