[英]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.