[英]loading a page without changing the url
我在.htaccess
有太多RewriteRule
。
现在,我想删除那些RewriteRule
并使用php加载或重定向我的链接。
为此,我使用header
但是当我使用header
时,浏览器中的原始URL正在更改。
例如:我的原始链接: http://test.com/something/someID
: http://test.com/something/someID
,当我使用标题时,它更改为: http://test.com/page.php?id=
: http://test.com/page.php?id=
id http://test.com/page.php?id=
最重要的是,我需要使用vbseo(vbulletin)之类的东西来管理我的链接,而无需使用RewriteRule
,但是当然,我在.htaccess
包含以下代码,将我的所有链接重定向到某个特定页面。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php [L,QSA]
只是不要提供任何标题。 默认情况下,重定向的链接保持不变。 (即使服务器将其重定向,也将透明地传递给客户端)。 因此,您需要将其传递给index.php,但要使用原始路由的GET值。
所以...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f #If requested filename is not a file
RewriteCond %{REQUEST_FILENAME} !-d #If requested filename is not a directory
RewriteRule ^(.+)$ index.php?route=$1 [L,QSA]
因此example.com/this/is/a/test
会重定向到example.com/index.php?route=this/is/a/test
,然后您可以签入index.php文件并根据需要重新路由$_GET['route']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.