This is a discussion on Mod Rewrite within the Apache Web Server forums, part of the Web Server and Related Forums category; Hello, I have writen this script in .htaccess: RewriteEngine on RewriteBase / RewriteRule pers/(.*) http://www.mysite.net/personals/skpers.php?...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I have writen this script in .htaccess: RewriteEngine on RewriteBase / RewriteRule pers/(.*) http://www.mysite.net/personals/skpers.php?u=$1 [L,R] It is ok, infact if i write: www.mysite.net/pers/example it redirecto to: www.mysite.net/personals/skpers.php?u=example But i must do this way: if write: www.mysite.net/?example it redirect to: www.mysite.net/personals/skpers.php?u=example I have tried with this script: RewriteEngine on RewriteBase / RewriteRule pers/^/?(.*) http://www.mysite.net/personals/skpers.php?u=$1 [L,R] But don't work, why? Thanks |
|
|||
|
Soho wrote:
> Hello, > > I have writen this script in .htaccess: > > RewriteEngine on > RewriteBase / > RewriteRule pers/(.*) http://www.mysite.net/personals/skpers.php?u=$1 [L,R] > > It is ok, infact if i write: > > www.mysite.net/pers/example > > it redirecto to: www.mysite.net/personals/skpers.php?u=example > > But i must do this way: > > if write: > > www.mysite.net/?example > > it redirect to: www.mysite.net/personals/skpers.php?u=example > > I have tried with this script: > > RewriteEngine on > RewriteBase / > RewriteRule pers/^/?(.*) http://www.mysite.net/personals/skpers.php?u=$1 > [L,R] > > But don't work, why? http://www.mysite.net/?example The ?example part is not part of the URI, but it is in the query string. If you want to create rules based on the query string, I believe that you have to do use RewriteCond with %{QUERY_STRING} followed by the rule. I haven't tried anything like this myself. One option that you also have is to make your php file redirect the request with the header function. For instnace, you may do something like this at the very beginning of the script: <?php if(count($_GET)===1){ // if there is only one _GET variable foreach($_GET as $key=>$val) header('Location: http://www.mysite.net/pers/'.$key); exit; } ?> -- Justin Koivisto - spam@koivi.com PHP POSTERS: Please use comp.lang.php for PHP related questions, alt.php* groups are not recommended. |