We help IT Professionals succeed at work.

simple url rewriting

Hello experts;
I want to use this url rewriting (.htaccess)

http://www.mysite.com/ana

so it points to
http://www.mysite.com/artiste-bio.php?username=ana

Any clues ?

I use linux / apache / php
Comment
Watch Question

Try this:

RewriteRule http://www.mysite.com/([^/]*)$ http://www.mysite.com/artiste-bio.php?username=$1 [L]

Open in new window

Author

Commented:
does not seem to work.
Besides I just realized : it will work badly with files like /images /scripts /admin etc..
Do you have a suggestion to simplify this kind of url ?

http://www.mysite.com/artiste-bio.php?username=ana

Regards
Top Expert 2013

Commented:
What are you using the parameter for; a re-direct or query?


Cd&

Author

Commented:
for a SQL quesry
Top Expert 2013

Commented:
Okay you currently hit http://www.mysite.com/ana where it by default goes to http://www.mysite.com/ana/index.php

so why not do a php re-direct in index.php like this

header("Status: 301 Moved Permanently");

header("Location:http://www.mysite.com/artiste-bio.php?". $_SERVER['QUERY_STRING']);

Open in new window




Cd&

Author

Commented:
No,
I think I expressed myself badly

http://www.mysite.com/ana   goes to  http://www.mysite.com/artiste-bio.php?username=ana
http://www.mysite.com/john goes to  http://www.mysite.com/artiste-bio.php?username=john
etc...
except for
http://www.mysite.com/images/
http://www.mysite.com/scripts/
http://www.mysite.com/admin


Is it something that can be done with .htaccess ?

regards
Top Expert 2013
Commented:
If the rewrite that Roads_Roads does not do it than I have no idea.

What I gave you should work, but you have to set up the index.php for each of their directories.

You are doing a major structural change in the file system, so there is some work involved.

I wish I had more for you.  There may be some other rewrite rule that could be used but I don't use rewrite enough to be definitive about whether it is possible.


Cd&