adamjblakey Posted February 21, 2008 Share Posted February 21, 2008 Hi, What i have done is set-up links like this: <a href="{$domain}/corporate-events/{$result.subcategory|stripres}.html" title="Corporate Events - {$result.subcategory}" class="submenu">{$result.subcategory}</a> With the re-write rule: RewriteRule ^corporate-events/(.*)\.html$ entertainment-listings.php?title=$1 This is working fine but what i want to do now is have the link like this: <a href="{$domain}/{$resultb.region|stripres}/{$cat}/{$pagename|stripres}.html" title="{$resultb.area} - {$resultb.region}" class="submenu">{$resultb.region}</a> What would the re-write be on this? Cheers, Adam Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/ Share on other sites More sharing options...
dave420 Posted February 21, 2008 Share Posted February 21, 2008 Have you thought about rewriting every request that's not to an existing asset to a single PHP file, then have that file determine which PHP scripts to include? That way you have a single place where every page request starts from, where you can put your authentication/database/libraries/etc., at a very low overhead. Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472659 Share on other sites More sharing options...
adamjblakey Posted February 21, 2008 Author Share Posted February 21, 2008 No i have not though about doing that but want to get this one resolved first then think about a better way of doing the MOD Rewrite system. Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472662 Share on other sites More sharing options...
ToonMariner Posted February 21, 2008 Share Posted February 21, 2008 you will save yourself all manner of time and heartache by doing the whole hog inone go... http://www.alistapart.com/articles/succeed Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472665 Share on other sites More sharing options...
adamjblakey Posted February 21, 2008 Author Share Posted February 21, 2008 Although that does look interesting and a good route to go down, i am currently under pressure to get this working so i don't currently have the time to learn a new technique. If you could help me out with the rule in question i would appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472668 Share on other sites More sharing options...
ToonMariner Posted February 21, 2008 Share Posted February 21, 2008 well adam - the difficulty is that all of your url is dynamically generated!!! The only surefire thing in there is that you will have 3 forward slashes - and I bet your bottom dollar that other sections of the site have the same and you don't want them re-directing to the same script. what would be more beneficial is to name the php scripts after the sections you want to redirect to then you could have a general rule for re-direction like so RewriteRule ^([^/]*)/(.*)\.html$ $1.php?title=$2 and so on... Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472672 Share on other sites More sharing options...
adamjblakey Posted February 21, 2008 Author Share Posted February 21, 2008 Thanks for that.. This will actually be the only part of the website that will have 3 forward slashes. That being said would it be able to be done differently? Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472684 Share on other sites More sharing options...
adamjblakey Posted February 21, 2008 Author Share Posted February 21, 2008 I have resolved this now. This seemed to work fine. RewriteRule ^([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)\.html$ entertainment-region-listings.php?cat=$1&item=$2&other_item=$3 Quote Link to comment https://forums.phpfreaks.com/topic/92263-mod-rewrite-cannot-work-out-the-correct-rule/#findComment-472719 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.