![](/img/trans.png)
[英]How to navigate to another page without reloading the whole page in NextJs?
[英]how to navigate to another page of my website without reloading header in php
到目前为止,我一直在使用GET变量,当单击链接/按钮时,该变量将传递到URL,然后index.php
页面将加载该页面。
例如-默认情况下,网站会加载index.php
页面,其中包括header.php
, home.php
, footer.php
; 单击关于我们按钮时,会将GET变量?page = aboutUs is passed to URL and then
index.php includes
aboutUs.php along with
header.php and
footer.php`。
但我不想让变量传递,而是我希望url像.../home/
和.../aboutUs/
还有其他方法吗?
使用.htaccess制定重写规则。
尝试这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)/$ /$1.php
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
DirectoryIndex index.php
ErrorDocument 404 /404-error.php
我认为这应该工作。 只是重定向像
<a href="about">about</a>
而且页面应该在about.php
类的about.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.