rickythakrar Posted May 17, 2007 Share Posted May 17, 2007 I will attempt to present the problem in the simplest way possible. Desired result (to work dynamically with any string) URL address bar physical page home home/ domain.com/index.php?x=home home/ home/ domain.com/index.php?x=home images/logo.gif images/logo.gif images/logo.gif The rules in words 1. Where there is a slash at the end, redirect [working] 2. Where there is no slash or dot in the URI, add a trailing slash 3. Where there isn't a file or directory existing, redirect Working 1. RewriteRule ^(.+)/$ http://findanecohome.co.uk/index.php?x=$1 [nc,qsa] Attempts 2. RewriteRule ^((.+)!\.(.+))/$ http://findanecohome.co.uk/$1/ [nc,r,qsa] 3. RewriteCond %{REQUEST_URI} !-f RewriteCond %{REQUEST_URI} !-d RewriteCond ^(.+)$ http://findanecohome.co.uk/index.php?x=$1 [nc,qsa] Link to comment https://forums.phpfreaks.com/topic/51791-solved-complex-dynamic-mod_rewrite/ Share on other sites More sharing options...
rickythakrar Posted May 17, 2007 Author Share Posted May 17, 2007 Gargh! You work on something for two days, post it on a forum and work it out 5 minutes later. *sigh* Anyway, this is the final solution: RewriteRule ^([A-Za-z0-9-]+)$ http://domain.co.uk/$1/ [are,l,nc,qsa] RewriteRule ^([A-Za-z0-9-]+)/$ http://domain.co.uk/index.php?x=$1 [l,nc,qsa] I think it meets all the rules. Link to comment https://forums.phpfreaks.com/topic/51791-solved-complex-dynamic-mod_rewrite/#findComment-255185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.