Home > Blockchain >  htaccess match after ~ and pass as url parameter
htaccess match after ~ and pass as url parameter

Time:04-02

i want rewrite my url with htaccess. So, i want for example that

https://sample.com/~X6y2 has a match and it passes all behind the '~' as parameter to https://sample.com/req.php?id=[here]

is it possible with the '~'-character? so, if not, i need an alternative. Maybe '@'-Charakter, like tiktok.

So, it should match e.g. https://sample.com/~AZaz09, https://sample.com/~0123

but not https://sample.com/0123, https://sample.com/AZaz09, https://sample.com/XY/~Z1234,...

I've tried several regex but nothing has provided the desired function :(

Best of these is (but not working, idk why):

RewriteEngine on

RewriteRule ^.*\/[\~]([a-z][^.]*)$ req.php?id=$1 [NC,L]

I'm new to regex and htaccess, so it's a bit difficult for me. I would be grateful if someone would provide a working htaccess including regex. Thx ✌

  • Related