Mod Rewrite

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?...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-04-2004
Soho
 
Posts: n/a
Default Mod Rewrite

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


  #2 (permalink)  
Old 05-05-2004
Justin Koivisto
 
Posts: n/a
Default Re: Mod Rewrite

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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0