Home Rewrite profile.php?user=username to profile/username
Reply: 0

Rewrite profile.php?user=username to profile/username

user985
1#
user985 Published in April 22, 2018, 12:54 am

I've created a very basic php templating system that I'm using to display a page with this URL: /basedir/index.php?page=home

The home content is served by the script home.php.

With a rewrite rule in .htaccess, I want my url to look like this: /basedir/home.

The problem that I'm having is that I've got stuck when it comes to rewrite one more GET variable that I'm using to display a user's profile. For now the profile page url looks like this: /basedir/profile?user=username.

Now I want it to look like this: /basedir/profile/username.

So far, my .htaccess looks like this:

RewriteEngine On

RewriteBase /basedir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) ?page=$1 [L,QSA]

I have no idea if this is good or if i have to write a completely new .htaccess file.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306287 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO