php - How to keep only last parameter dynamic in clean url when multiple parameters present -


how can make last parameter of url dynamic when have more 1 parameters

for instance: http://localhost:8080/series/dynamics/testurl/shoes/sports

has 2 parameters namely "shoes" & "sports". achieve keep shoes static parameter & "sports" dynamic parameter can changed further "running","tennis" or "casual". below how have defined links in php:

<a href="<?php echo 'shoes'.'/'.$var2; ?>">sports</a><br/> <a href="<?php echo 'shoes'.'/'.$var2; ?>">running</a><br/> <a href="<?php echo 'shoes'.'/'.$var3; ?>">tennis</a><br/> <a href="<?php echo 'shoes'.'/'.$var4; ?>">casual</a><br/> 

while trying achieve through above code & htaccess problem user clicks on tennis while on "sports" url changes below:

http://localhost:8080/series/dynamics/testurl/shoes/shoes/tennis

or if when click on sports link 2nd time changes to:

http://localhost:8080/series/dynamics/testurl/shoes/shoes/sports

as result getting 404 not found error. hence hoping there must way keep 1st parameter staic , 2nd parameter dynamic. know not classic way of doing things have gon elementary level in order able narrow down on errors no luck yet !!!

i checked various sources nothing helpful resolve problem. please guide me in right direction.

.htaccess looks this:

rewriteengine on  rewritebase /series/dynamics/testurl/  rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d  rewriterule ^([a-za-z]+)/?$ test.php?page=$1 [l,nc,qsa]  rewriterule ^([a-za-z]+)/([^/]+)/?$ test.php?page=$1&subgroup=$2 [l,nc,qsa]  

looks case need <base> tag in html handle relative urls.

you can add below <head> section of page's html:

<base href="/series/dynamics/testurl/" /> 

so every relative url resolved base url , not current page's url.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -