我有一个网站http://mysite.com/index.php,还有一个子菜单:
- 主页 => http://mysite.com/index.php
- 关于我们 => http://mysite.com/about.us.php
- 产品 => http://mysite.com/products.php
但是我想让http://mysite.com/index.php处理所有请求,然后使用Ajax请求仅更改内容。这样,网站只加载内容部分,速度更快,易于导航。
问题在于SEO,因为Google只能看到http://mysite.com/index.php这个URL,而我希望将http://mysite.com/about-us与“关于我们”内容相关联,将http://mysite.com/product与“产品”内容相关联,等等。
我知道可以用PHP读取URL并实时编写Ajax,但这样会重新加载整个页面。有没有不重新加载整个页面的方法呢?
我认为需要在子菜单中有一个常规锚点,例如指向“http://mysite.com/contact-us”但是当单击时,代替打开此页面,处理Ajax请求。
如果这是可能的,Google可能会认为这是黑帽子技术,对吗?
问候 Alex
echo "<script>window.history.pushState('', '', 'http://desired.url.here');</script>";
……(来自下面埋藏的答案。) - ashleedawg