Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

url rewrite question for dynamic url

Status
Not open for further replies.

keak

Programmer
Sep 12, 2005
247
CA
I am trying to improve my url format, currently i have something like
test.php?variable1=value1&variable2=value2
and I want it to be like
test.php/variable1/value1/variable2/value2/

I have the following rewrite rule,
RewriteRule (.*?\.php)(\?[^/]*)?/([^/]*)/([^/]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]

but the following is my problem.

I have relative paths to different resources including css, images, etc.

I corrected both my css and image links to web server absolutes ... so from ../images/test.gif to /images/test.gif

This corrected the IIS linking problem, but when I view the url of the image, I am seeing soemthing like

/test.php/variable1/value1/images/art_tabblue_left.gif

Is there a better rewrite rule to handle these type of dynamic URL that doesn't break resource links?

Or will I have to handle each file individually?
 
Hi

First at all, your regular expression looks abit strange. There are two consecutive quantifiers ( the asterisc ( * ) and the question mark ( ? ) ) after one metacharacter ( the period ( . ) ).

Correct this and try again. ( And please put your code between [ignore]
Code:
...
[/ignore] tags. )

Feherke.
 
test.php?variable1=value1&variable2=value2
and I want it to be like
test.php/variable1/value1/variable2/value2/

I'd like to take this concept a step further. What would I put in my .htaccess file if I wanted (let's pretend text.php is now called 'index.php') to now show the php file?

so the url is now site>.com/variable1/value1/variable2/value2/

How do I present it so that apache will refer this URL to the file site>.com/index.php ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top