且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用AJAX从.php文件中加载内容?

更新时间:2023-12-05 10:58:10

最后编辑/答案:

我找到了问题的答案-实际上,该问题与AJAX/History.js无关,但与本地测试服务器有关.

I found an answer to my question - actually the issue wasnt related to AJAX / History.js, but had to do with my local test-server.

为了重写URL,以便链接可以无扩展名起作用,请在.htaccess中添加以下规则,然后将其放置在服务器的根目录中-现在,如果链接看起来像这样,则将同时加载.html和.php页面<a href="/home">About</a>

In order to rewrite urls so link will work with no extension, add the following rules in an .htaccess og place it in root of server - now both .html and .php - pages will load if the link looks like this <a href="/home">About</a>

选项+关注符号链接

RewriteEngine开启

RewriteEngine On

RewriteCond%{REQUEST_FILENAME}!-d

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond%{REQUEST_FILENAME} .html -f

RewriteCond %{REQUEST_FILENAME}.html -f

RewriteRule ^(.*)$ $ 1.html

RewriteRule ^(.*)$ $1.html

RewriteCond%{REQUEST_FILENAME}!-d

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond%{REQUEST_FILENAME} .php -f

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^(.*)$ $ 1.php

RewriteRule ^(.*)$ $1.php