Soho wrote:
> Hello,
>
> I have writen this script in .htaccess:
>
> RewriteEngine on
> RewriteBase /
> RewriteRule pers/(.*) <a style='text-decoration: underline;' href="http://www.mysite.net/personals/skpers.php?u=$1" target="_blank">http://www.mysite.net/personals/skpers.php?u=$1</a> [L,R]
>
> It is ok, infact if i write:
>
<font color=purple> > <a style='text-decoration: underline;' href="http://www.mysite.net/pers/example</font" target="_blank">www.mysite.net/pers/example</font</a>>
>
<font color=purple> > it redirecto to: <a style='text-decoration: underline;' href="http://www.mysite.net/personals/skpers.php?u=example</font" target="_blank">www.mysite.net/personals/skpers.php?u=example</font</a>>
>
> But i must do this way:
>
> if write:
>
<font color=purple> > <a style='text-decoration: underline;' href="http://www.mysite.net/?example</font" target="_blank">www.mysite.net/?example</font</a>>
>
<font color=purple> > it redirect to: <a style='text-decoration: underline;' href="http://www.mysite.net/personals/skpers.php?u=example</font" target="_blank">www.mysite.net/personals/skpers.php?u=example</font</a>>
>
> I have tried with this script:
>
> RewriteEngine on
> RewriteBase /
<font color=purple> > RewriteRule pers/^/?(.*) <a style='text-decoration: underline;' href="http://www.mysite.net/personals/skpers.php?u=$1</font" target="_blank">http://www.mysite.net/personals/skpers.php?u=$1</font</a>>
> [L,R]
>
> But don't work, why?
<a style='text-decoration: underline;' href="http://www.mysite.net/?example" target="_blank">http://www.mysite.net/?example</a>
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: <a style='text-decoration: underline;' href="http://www.mysite.net/pers/" target="_blank">http://www.mysite.net/pers/</a>'.$key);
exit;
}
?>
--
Justin Koivisto - spam RemoveThis @koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
>> Stay informed about: Mod Rewrite