[英]How do I rewrite URL using .htacess without consequences for $_GET data
我想用一些$ _GET數據更改我的URL,例如:
http://www.website.com/articles.php?article=article_title_stored_in_database
http://www.website.com/simple_page.php?page=page_title_stored_in_database
並使它們看起來像這樣:
http://www.website.com/articles/article_title_stored_in_database/
http://www.website.com/pages/page_title_stored_in_database/
另一個問:如果我更改了內部帶有$ _GET數據的URL,更改后是否可以訪問它們? 所以如果地址是:
http://www.website.com/articles/article_title_stored_in_database/
變量$ _GET ['article']會返回'article_title_stored_in_database'嗎? 謝謝。
您可以在DOCUMENT_ROOT/.htaccess
文件中使用這些規則:
Options -MultiViews
RewriteEngine On
RewriteRule ^articles/([^/]+)/?$ articles.php?article=$1 [L,QSA,NC]
RewriteRule ^pages/([^/]+)/?$ simple_page.php?article=$1 [L,QSA,NC]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.