本文介绍了我的虚拟主机是添加?PHPSESSID = fgh2h45 ......到URL的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用iPage.com主机。为了在自己的主机使用PHP的会议我需要添加 session_save_path('/家庭/用户/网络/.../的cgi-bin / tmp目录'); 在每一页的开始(在我的情况下,只有的index.php,因为一切都槽的index.php在前)。

I'm using iPage.com host. In order to use PHP sessions in their host I need to add session_save_path('/home/users/web/.../cgi-bin/tmp'); at the start of each page (in my case only index.php because everything goes trough index.php first).

现在,它们会自动会话ID添加到请求这样每个URL的末尾:website.com/movies/details/?PH​​PSESSID=4s54kjhdl ...

Now, they automatically add the session id to the end of every URL requested like this: website.com/movies/details/?PHPSESSID=4s54kjhdl...

我认为这是造成问题,可能会影响谷歌的索引和搜索引擎优化。

I think this is causing problems and can affect google indexing and SEO..

如何prevent呢?

How to prevent this?

推荐答案

您的主机是不是造成问题,PHP被追加这一数据。具体来说,PHP被设置为 PHPSESSID 变量添加到URL,让PHP来跟踪会话。这是可能通过更新php.ini文件使用更改相关设置的ini_set 调用之前在session_start ,或者更永久(虽然因为你主持这个最后的选择可能是出)。 的可用会话运行时设置的列表。

Your "host" isn't causing the issue, PHP is appending this data. Specifically, PHP is configured to append the PHPSESSID variable to the URL to allow PHP to track the session. It's possible to change the relevant setting using ini_set prior to calling session_start, or more permanently by updating the php.ini file (though since you're hosted this last option is probably out). This is a list of the available runtime settings for sessions in PHP.

虽然可以控制值是否被添加到您的网址的结尾,它需要跟踪的会话。另外,您可以配置PHP来使用Cookie来跟踪会话,但需要cookie来跟踪会话可能会打破你的申请谁拒绝Cookie的用户。

While you can control whether or not the value is appended to the end of your URLs, it's required to track the sessions. Alternatively you can configure PHP to use cookies to track sessions, but requiring cookies to track sessions may break your application for users who reject cookies.

总之,你可以控制会话ID,使其一点点prettier(重命名PHPSESSID的东西更适合或使更少神秘的值),但除非你想利用cookies来维护会话,你'再坚持你的网址这个垃圾。如果你的只有的使用cookies有些用户可能无法维持会话。

In short, you can control the session ID to make it a little prettier (by renaming PHPSESSID to something more amenable or making the value less cryptic) but unless you want to use cookies to maintain the session, you're stuck with this "garbage" on your URL. If you only use cookies some users may not be able to maintain the session.

要启用基于cookie的会话处理,你可以既可以执行:

To enable cookie based session handling you can execute either:

// stop PHP from automatically embedding PHPSESSID on local URLs
ini_set('session.use_trans_sid', false);

// only use cookies (no url based sessions)
ini_set('session.use_only_cookies', true);

这篇关于我的虚拟主机是添加?PHPSESSID = fgh2h45 ......到URL的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 10:21