开发者

.htaccess grab whole path

开发者 https://www.devze.com 2023-03-11 13:36 出处:网络
i\'m experimenting with a method for pretty urls i haven\'t tried before where htaccess just grans the whole path after the root and passes it as a single variable, then i will break it up into specif

i'm experimenting with a method for pretty urls i haven't tried before where htaccess just grans the whole path after the root and passes it as a single variable, then i will break it up into specific variables using php explode, but i'm getting stuck early on.

I'm using this line to grab everything in the url after "blah.com" -

RewriteRule ^(.*)$  index.php?url=$1 [NC]

then in php use this line to turn it into a variable

$url = $_GET['url'];

but when i test it with a fake path, like "blah.com/test/test2" $url echos as "index.php" instead of "test/test2"

i hate working with htaccess,开发者_运维百科 which is one of the reasons im trying this method, so i'm not sure what i need to do to fix this. any help would be... very helpful!


Don't bother with GET variables, just inspect $_SERVER['REQUEST_URI'], infinitely simpler :)

0

精彩评论

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