URL rewrite Show url parameter 2 and hide paramter 1

Discuss practical ways rearrange URLs using mod_rewrite.

URL rewrite Show url parameter 2 and hide paramter 1

Postby Allen » Fri Jan 16, 2009 6:43 am

Here is what I want to accomplish.

www.example.com/dm.php?record=test&page=name

I want to show it as

www.example.com/name

or

www.example.com/name.php

I have been attempting to modify this code

Options +FollowSymLinks
RewriteEngine on

RewriteRule (.*)/(.*)\.php dm.php?record=$1&page=$2

which only gets me

www.example.com/test/page.php

can anyone help me out with this...
Allen
 
Posts: 2
Joined: Fri Jan 16, 2009 12:16 am

Postby richardk » Sat Jan 17, 2009 6:16 pm

Does record=test change? If it does, it either needs to be in the URL or you need some way to find out that value.

You can do this using a RewriteMap if you have access to the httpd.conf file or you will need to edit your PHP script.

If it doesn't
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([^/]+)/([^.]+)\.php$ /dm.php?record=test&page=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Allen » Fri Jan 23, 2009 1:51 am

Sorry for the lon reply time I had to reformt my entire computer and nuke my server. Not fun.

No the first record is set and does not need to change. its works so thank you.
Allen
 
Posts: 2
Joined: Fri Jan 16, 2009 12:16 am

Postby richardk » Fri Jan 23, 2009 11:21 am

It should have been
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^[^/]+/([^/]+)\.php$ /dm.php?record=test&page=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 25 guests

cron