到目前为止,我一直在使用 GET 变量,当单击链接/按钮时,该变量会传递到 URL,然后 index.php
页面会加载该页面。
例如-默认情况下网站加载index.php
页面,它包括header.php
、home.php
、footer。 php
;单击“关于我们”按钮时,GET 变量 ?page=aboutUs 会传递到 URL,然后
index.php包含
aboutUs.php以及
header .php和
footer.php`。
但我不想传递 get 变量,而是希望 url 类似于 .../home/
和 .../aboutUs/
还有其他方法吗?
最佳答案
使用 .htaccess 制定重写规则。
试试这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)/$ /$1.php
关于javascript - 如何导航到我网站的另一个页面而不用在 php 中重新加载 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47989649/