我想用一些$ _GET数据更改我的网址,例如:
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数据的网址,是否可以在更改后访问它们?所以如果地址是:
http://www.website.com/articles/article_title_stored_in_database/
变量$ _GET ['article']会返回'article_title_stored_in_database'吗? 谢谢。
答案 0 :(得分:1)
您可以在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]