-2

Anyone can help me, i want to rewrite url from

http://www.fvilla.in/single.php?username='ankit12541'

to

http://fvilla.in/ankit12541

  • possible duplicate of [htaccess Redirect directory name to parameter](http://stackoverflow.com/questions/21662957/htaccess-redirect-directory-name-to-parameter) – Panama Jack Mar 07 '15 at 22:01
  • 1
    Rewriting a URL in PHP? Why that? Just take the "new" url and all is fine. What is the question here? I assume you want to rewrite inside the http servers rewriting module by specifying a rule in a `.htaccess` style file. But in that case the direction of the rewriting as shown in your question does not make sense... – arkascha Mar 07 '15 at 22:03
  • better use an example domain for examples. See: http://en.wikipedia.org/wiki/Example.com – Jonas Stein Mar 07 '15 at 22:19

1 Answers1

0

I believe you mean rewriting the URL using the .htaccess file. Your file should look like this:

Options -Indexes
Options +FollowSymLinks
<IfModule mod_rewrite.c>
 RewriteEngine On

 RewriteCond %{HTTP_HOST} ^fvilla.in$ [NC]
 RewriteRule ^/([^/]+)$ /single.php?username=$1
</IfModule>

That would work, but it doesn't really make sense, since it would rewrite any URL in your domain.

So it would be better to do

http://www.fvilla.in/single.php?username='ankit12541'
 to
http://fvilla.in/user/ankit12541

using the .htaccess file like this:

Options -Indexes
Options +FollowSymLinks
<IfModule mod_rewrite.c>
 RewriteEngine On

 RewriteCond %{HTTP_HOST} ^fvilla.in$ [NC]
 RewriteRule ^/user/([^/]+)$ /single.php?username=$1
</IfModule>
Edwin Krause
  • 1,766
  • 1
  • 16
  • 33