Social network forwarding htacess

A quick question for you guys, I am creating a php / mysql site and I am facing a little problem, I have profiles on my site where a random user profile will have the following link for example: www.MyDomain.com/profile.php? username = a

What I would like to do is show something like this in the address bar: www.MyDomain.com/abc

Also, if someone types in: www.MyDomain.com/abc, they should take it to the profile "abc", which is actually www.MyDomain.com/profile.php?username=abc

Any ideas? Thanks in advance!

+3


source to share


2 answers


I'm not 100% sure how to do this with root / level, but I think this should work:

RewriteEngine on
RewriteBase /
RewriteRule ^([^/\.]+)/?$ profile.php?username=$1 [L]

      



Here's a real neat site that you can use to test your rules.

+1


source


What you are looking for is mod rewrite. There are a couple of decent generators. Play with them:

http://www.generateit.net/mod-rewrite/



http://www.myseotool.com/free-seo-tools/htaccess-url-rewrite-generator.php

http://www.webmaster-toolkit.com/mod_rewrite-rewriterule-generator.shtml

0


source







All Articles