Reputation: 372
I have a link www.example.com
and www.example.com/user/username
how can I redirect it so that when someone accesses www.example.com/username
they get the same thing as if they used user
?
So these links would be the same pages:
www.example.com/user/username/profile
-> www.example.com/username/profile
www.example.com/user/username/messages
-> www.example.com/username/messages
www.example.com/user/username/chats
-> www.example.com/username/chats
Is there something I can change in .htaccess to achieve this result?
Upvotes: 2
Views: 38
Reputation: 785481
You can use this rule in your site root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!user/).+$ user/$0 [L,NC]
Upvotes: 1