I'm trying to rewrite everything from my website to a file index.php with a query parameter that contains requested path, but when I just simply do RewriteRule ^(.*)$ index.php?url=$1 [L]
my index.php file displays that url contains index.php... Simply, I want to type localhost/123 or localhost/123.php and always get the path part in my url parameter.
print_r($_GET['url'])
outputs Array ( [url] => index.php )
no matter what path part is.
Sorry for my English, hope u'll understand what I mean :)
Try using a different flag in your RewriteRule
Instead of [L]
RewriteRule ^(.*)$ index.php?url=$1 [L]
Try something like [QSA]
RewriteRule ^(.*)$ index.php?url=$1 [QSA]
For a list and information of the different types of flags, check out Apache's Documentation
http://httpd.apache.org/docs/current/rewrite/flags.html
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.