never_rain Posted May 5, 2008 Share Posted May 5, 2008 I am new into URL rewrite. I have a task to re write a URL which looks like this. www.domain.com/index.php?pg=detail&catId=1&catTitle=2 [nc] After rewrite, it should look like this www.domain.com/aboutus.html (about us is the cat title so it will change with every argument) However, I have achieved the following. www.domain.com/detail/8/aboutus.html I have used the following line of code to get this result. RewriteRule ^detail/(.*)/(.*)$ /sitewonders/index.php?pg=detail&catId=$1&catTitle=$2 [nc] What my requirement is that I dont want to show detail and 8 whereas detail is the page where my codes are stored and 8 is the product category.I have not clue how to get hold of this. Please give me any clue or help to achieve this target. Thanks Link to comment https://forums.phpfreaks.com/topic/104161-url-rewrite-issue/ Share on other sites More sharing options...
Michan Posted May 5, 2008 Share Posted May 5, 2008 Try this: RewriteRule ^aboutus.html$ /sitewonders/index.php?pg=detail&catId=1&catTitle=2 Link to comment https://forums.phpfreaks.com/topic/104161-url-rewrite-issue/#findComment-533262 Share on other sites More sharing options...
never_rain Posted May 5, 2008 Author Share Posted May 5, 2008 Try this: RewriteRule ^aboutus.html$ /sitewonders/index.php?pg=detail&catId=1&catTitle=2 aboutus.html is an example. As I said, aboutus is fetched by using catTitle so if the value of catTitle is profile, so it should show profile.html and if the value in catTitle is services then it should show services.html. Link to comment https://forums.phpfreaks.com/topic/104161-url-rewrite-issue/#findComment-533268 Share on other sites More sharing options...
Michan Posted May 5, 2008 Share Posted May 5, 2008 Alright, then give this a try: RewriteRule ^([^/]+)(/([^/]+))?.html$ /sitewonders/index.php?pg=detail&catId=%3&catTitle=%1 Good luck! Link to comment https://forums.phpfreaks.com/topic/104161-url-rewrite-issue/#findComment-533274 Share on other sites More sharing options...
never_rain Posted May 5, 2008 Author Share Posted May 5, 2008 Alright, then give this a try: RewriteRule ^([^/]+)(/([^/]+))?.html$ /sitewonders/index.php?pg=detail&catId=%3&catTitle=%1 Good luck! Thanks for your help. I need to show you the menu file where I have put the a href code. I am not sure how to call your provided parameters. If you can just have a look at it. <a href="<?=$webPath?>detail/<?=$viewcat['pk_id']?>/<?=str_replace(' ', '_', $viewcat['cat_Title'])?>.html" class="b"> $webpath is the URL of my site. detail you already know but using your provided code, what should I pass there.. I have no clue about it. Thanks again for your help. Link to comment https://forums.phpfreaks.com/topic/104161-url-rewrite-issue/#findComment-533275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.