lango13 Posted April 17, 2008 Share Posted April 17, 2008 I am currently stuck trying to work out a mod rewrite issue that I have been stuck on for a while. What I am trying to do is convert every url within my website so that it looks like this: www.url.com/index/id/1/colour/blue --> www.url.com/index.php?id=1?colour=blue www.url.com/otherpage/otherid/2/colour/green/size/small --> www.url.com/otherpage.php?otherid=2&colour=green&size=small --> So every page within the website will always have its url broken down and separated by a /. Thanks, J Quote Link to comment Share on other sites More sharing options...
ucffool Posted April 17, 2008 Share Posted April 17, 2008 I'm by no means a mod_rewrite expert, but I think you can't have logic like you are expecting within mod_rewrite rules. You have to tell it how to breakdown /something/else/elseagain/yup into the appropriate file. It doesn't have the capacity to guess that if you add another /something it would be the color. Quote Link to comment Share on other sites More sharing options...
lango13 Posted April 18, 2008 Author Share Posted April 18, 2008 I have been told that the following will work... but it doesnt seem to want to work. Code: RewriteCond %{REQUEST_URI} ^/?(index|otherpage) [NC] RewriteRule .? %1.php?d=%{REQUEST_URI} [QSA,L] PHP Code: <?php if ( isset( $_GET['d'] ) ) { $parts = explode( '/', $_GET['d'] ); array_shift( $parts ); // Remove the file entry. for ( $i = 0, $l = count( $parts); $i < $l; $i++ ) { $_GET[ $parts[ $i ] ] = $parts[ ++$i ]; } } </php> Quote Link to comment 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.