我怎麼能改寫這樣的URL:URL重定向URL與查詢字符串,並將其用於回聲(URL路由?)
example.com/page.php?link=Anythingelse to example.com/Anythingelse and using
<h1><?php echo $link; ?></h1>
這與內容PHP:
輸出示例:網站-Title:Anythingelse - 網站標題和標題1 Anythingelse
第一個想法是:
RewriteEngine On
# Redirect e.g. /page.php?link=value to /value if direct acccess
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^link=([^&]+)$
RewriteRule ^/?page\.php$ /%1 [R=301,QSD,NE,L]
# Internal rewrite to from /value to /page.php?link=value
RewriteCond %{REQUEST_URI} !^/?page\.php$
RewriteRule ^/?([^/]+)$ /page.php?link=$1 [QSA,NE,L]
但它會導致500內部服務器錯誤。我的提供程序不支持Apache錯誤日誌。我能做什麼?使用PHP進行URL路由?
你[看着它(https://www.addedbytes.com/blog/url-rewriting-for-beginners)? – Wndrr
關於URL重寫有很多問題,教程,指南等。請先做一些研究並嘗試。 –
的[URL與PHP重寫]可能的複製(https://stackoverflow.com/questions/16388959/url-rewriting-with-php) – Neodan