URL rewrite PHP $_GET variable

喜你入骨 提交于 2019-12-21 22:48:21

问题


Hey, I am looking to make a .htaccess rewrite file to change:

newProject/index.php?start=2

to

newProject/page/2

How might I go about this? Thanks!


回答1:


I think your question is backwards, especially if you are looking for cleaner URLs.

RewriteEngine On
RewriteRule ^newProject/page/(\d+)$ /newProject/index.php?start=$1

I assume that your users will click on URLs like /newProject/page/2, and a PHP script at newProject/index.php will access $_GET['start'] to read the page number.




回答2:


If you're using Apache 2.2.12 or later, consider using the FallbackResource directive instead. See http://httpd.apache.org/docs/trunk/rewrite/remapping.html#fallback-resource for discussion of alternate techniques.



来源:https://stackoverflow.com/questions/5177738/url-rewrite-php-get-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!