Communications Technology Articles - Wordpress Themes - Debt Consolidation - Kamala Harris - Bob's Free Stuff Forum

PDA

View Full Version : mod_rewrite, printing $1-$2 to page?


brianj
Apr 26th 2009, 1:20 am
Hi, simple problem:

I created a mod_rewrite rule


RewriteRule ^(.*)-(.*)$ index.php?keyword1=$1&keyword2=$2 [L]
#the url i want: mysite.com/keyword1-keyword2



How can i make that these 2 variables are printed out on access?

something like:
echo $1;
echo $2;

??

Thanks for help

MakeADifference
Apr 26th 2009, 1:29 am
Try this:

RewriteRule ^([^.]+)-([^.]+)$ index.php?keyword1=$1&keyword2=$2 [L]

OR

RewriteRule ^(.*?)-(.*?)$ index.php?keyword1=$1&keyword2=$2 [L]

brianj
Apr 26th 2009, 1:50 am
hey thanks,

i think the problem is on the php side:

<?
print $1;
print $2;
?>

.. how can i read these 2 variables mysite.com/keyword1something-keyword2something ??


All i want is to have them printed as:

keyword1something
keyword2something

koko5
Apr 26th 2009, 2:07 am
You've to echo $_gets:echo 'keyword1: '.$_GET['keyword1'].'<BR />keyword2: '.$_GET['keyword2'];

Regards

brianj
Apr 26th 2009, 2:22 am
yeah awesome, that's it! thanks!!! :)