Sorry if this question has been asked a ton however, I couldn't find a solution based off previous questions asked on this site and google.
I have this URL http://mywebsite.com/index.php?action=users&user=John
to generate a profile for a user. I would like to clean this URL so I can simply type http://mywebsite.com/users/John
or any action. Now, to go to a specific action, I can simply use:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
RewriteRule ^([a-zA-Z0-9\-]+)$ index.php?action=$1 [L]
then visit http://mywebsite.com/users
to visit the users page but to access a specific user I have &users=John
. I thought I could simply use:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ index.php?action=$1&$2=$3
to make my URL work like so http://mywebsite.com/action/extra_action
. Confusing? Without cleaning the url I would have http://mywebsite.com/index.php?action=ACTION&OTHER=
. Some actions don't require &other=
and would lead to a different page if you add on to it. For example, /index.php?action=users
leads to a page where a list is generated; index.php?action=users&user=John
leads to a dynamic profile of John. I would like to make the URL http://mywebsite.com/users
or if they want to visit a profile /users/John
. Thanks for reading!