Generic PHP Variable Rewrite?

Discuss practical ways rearrange URLs using mod_rewrite.

Generic PHP Variable Rewrite?

Postby Guest » Mon Oct 28, 2002 2:15 am

I am looking to produce a rewrite somthing like this...
Code: Select all
/browse/var1/1/var2/blah

Rewrites to:

/browse.php?var1=1&var2=blah

For any number of variables. Is this possible?
Guest
 

Re: Generic PHP Variable Rewrite?

Postby Guest » Sat Sep 06, 2003 7:24 pm

Anonymous wrote:I am looking to produce a rewrite somthing like this...
Code: Select all
/browse/var1/1/var2/blah

Rewrites to:

/browse.php?var1=1&var2=blah

For any number of variables. Is this possible?


It might me easier to read and easier to program the following instead. Because the filename will not need modification and the comma would replace the equal sign and the slash would replace the ampersand.

That way the slash does not have 2 meanings as in the above example.

Code: Select all
/browse.php/var1,1/var2,blah

Rewrites to:

/browse.php?var1=1&var2=blah
Guest
 

Re: Generic PHP Variable Rewrite?

Postby Trey Brister » Sat Sep 06, 2003 7:26 pm

I am really Trey not anonymous as in the last post.

Anonymous wrote:I am looking to produce a rewrite somthing like this...
Code: Select all
/browse/var1/1/var2/blah

Rewrites to:

/browse.php?var1=1&var2=blah

For any number of variables. Is this possible?


It might me easier to read and easier to program the following instead. Because the filename will not need modification and the comma would replace the equal sign and the slash would replace the ampersand.

That way the slash does not have 2 meanings as in the above example.

Code: Select all
/browse.php/var1,1/var2,blah

Rewrites to:

/browse.php?var1=1&var2=blah
Trey Brister
 
Posts: 1
Joined: Sat Sep 06, 2003 7:14 pm
Location: Dallas / Ft. Worth Area of Texas

Re: Generic PHP Variable Rewrite?

Postby Guest » Sat Sep 06, 2003 11:29 pm

Anonymous wrote:I am looking to produce a rewrite somthing like this...
Code: Select all
/browse/var1/1/var2/blah

Rewrites to:

/browse.php?var1=1&var2=blah

For any number of variables. Is this possible?

Hi,

you could use the following code into an .htaccess:

/.htaccess
Code: Select all
RewriteEngine On

RewriteRule ^browse/([^/]+)/([^/]+)/?(.*)$ /browse/$3?%{QUERY_STRING}$1=$2 [L]

RewriteRule ^browse/$ browse.php [L]


That should work...


:) Andrea
Guest
 

Postby pippo » Sat Sep 06, 2003 11:31 pm

Okay,
I had a page cached...it was me on the previous post.


Thanks,
:) Andrea
pippo
 
Posts: 6
Joined: Sat Sep 06, 2003 11:27 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 30 guests

cron