Reputation: 393
I'm trying to create nice URLs for the website.
I have this file structure:
public:
user:
user.php
index.php
I want to make it so that someone can enter the url:
http://www.example.com/user/{user name here}
and the request will be sent to:
user.php?name={user name here}
but I don't want them to see the file.
I think I may have to do this with .htacces but I'm not sure how.
I'm sorry if my question layout is not very good.
Upvotes: 1
Views: 119
Reputation: 785481
Place this rule in /user/.htaccess
:
Options -MultiViews
RewriteEngine On
RewriteBase /user/
RewriteCond %{THE_REQUEST} /user\.php\?name=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ user.php?name=$1 [L,QSA]
Upvotes: 2