.htaccess tutorial

htaccess Elite


Passing arguments to a SEF url

Ask your mod_rewrite and Redirection questions here, and get answers!

Passing arguments to a SEF url

New postby Naif » 29 Jan 2008 05:38

Hi guys. I am trying to achieve something for which I am not able to find any article. Been searching on google from the last 2 hours. I am pretty sure this is something unconventional but this is what I am trying to do.

I want a URL which looks like something.html?ref=naif

which should be interpreted as index.php?page=something&ref=naif

I am not sure how this is done but I am pretty much sure its either very easy or very very difficult!

This is what I am using currently:

Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^([^.]+)\.html index.php?page=$1 [L]


I use it for something.html but now I want to add an extra argument to this...

I'd appreciate if someone could help me out here or point me to an article :)

Thanks,
-- Naif
Naif
 
Posts: 2
Joined: 27 Sep 2007 02:48

Re: Passing arguments to a SEF url

New postby mod_rewrite » 30 Jan 2008 01:56

Naif wrote:I want a URL which looks like something.html?ref=naif

which should be interpreted as index.php?page=something&ref=naif


Code: Select all
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^([^.]+)\.html$ /index.php?page=$1 [L]
RewriteRule ^([^.]+)\.html?ref=(.+)$ /index.php?page=$1&ref=$2 [L]
mod_rewrite
 
Posts: 102
Joined: 30 Oct 2006 19:55


Return to Redirect or Rewrite Questions