I dont know much about htaccess and haven't found a solution for this issue.
I want that if a user opens example.com/@username/posts a php file is displayed and the username and page type (e.g. /posts/) is availiable as a get argument.
I already found this: RewriteRule "^user/([A-Z a-z 0-9_\-.]{1,})((/\w ) |/?)$" "/account/profile.php?name=$1"
but this isn't my usecase because its example.com/user/username
Do you know how to realise example.com/@username/posts orexample.com/@username/images with my htaccess or other stuff?
Thanks a lot, I am a newbie in this area :D Have a great sunday!
CodePudding user response:
Try:
RewriteRule "^@([\w.] )\/(. )$" "/account/profile.php?name=$1&page=$2"
^
and$
make it so that the expression in-between must try to match everything, not a sub-string.([\w.] )
matches and captures uppercase, lowercase, 0 to 9, underscore (_), hyphen and dot (the dot might not be required in your case, in which case you can change it to(\w )
).(. )
matches and captures as much a possible.