I need to pass URL along with all parameters through .htaccess to get in other php file. For example:
URL : abc.com/article/test1/test2/test3/?param1=1¶m=2
.htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ router.php?q=$1 [NC]
</IfModule>
router.php
echo $_GET['q'];
I am getting output as article/test1/test2/test3/
But i need output as article/test1/test2/test3/?param1=1¶m=2
Change the rule line to
RewriteRule .* router.php [END]
All the info you're looking for is right there, in PHP, in $_SERVER['REQUEST_URI']
which you can parse however you want.
问题是您的重写规则未保留参数,您需要在规则中添加[R=302,L]
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.