开发者

URL rewrite PHP $_GET variable

开发者 https://www.devze.com 2023-02-14 07:48 出处:网络
Hey, I am looking to make a .htaccess rewrite file to change: newProject/index.php?start=2 to newProject/page/2

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

newProject/index.php?start=2

to

newProject/page/2

How mig开发者_高级运维ht I go about this? Thanks!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消