[英]How do I rewrite URL using .htacess without consequences for $_GET data
I would like to change my URL with some $_GET data such as: 我想用一些$ _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
and make them look like this: 并使它们看起来像这样:
http://www.website.com/articles/article_title_stored_in_database/
http://www.website.com/pages/page_title_stored_in_database/
Another Q: If I change URL that had $_GET data inside, will it be possible to access them after the change? 另一个问:如果我更改了内部带有$ _GET数据的URL,更改后是否可以访问它们? So if the adress will be:
所以如果地址是:
http://www.website.com/articles/article_title_stored_in_database/
variable $_GET['article'] will return 'article_title_stored_in_database' ? 变量$ _GET ['article']会返回'article_title_stored_in_database'吗? Thank you.
谢谢。
You can use these rules in your DOCUMENT_ROOT/.htaccess
file: 您可以在
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.