February 14, 201016 yr Riiight, I made a post about this like year/year half ago, cant find it so ill make another, Want some SEO friendly urls this is what I got so far.. RewriteRule ^page/about$ http://www.irn3rd.co.uk/index.php?page=about [L] this lets me put in http://www.irn3rd.co.uk/page/about and it directs me to the page, but in the url it doesn't stay as that and goes to the ugly style url. How do I make this work dynamically? Many thanks Ben
February 15, 201016 yr Hi Ben, try this: RewriteEngine On RewriteRule ^(.*)/(.*)$ ./index.php?$1=$2 [NC] Dave
February 15, 201016 yr Author Hi Ben, try this: RewriteEngine On RewriteRule ^(.*)/(.*)$ ./index.php?$1=$2 [NC] Dave Superb that worked... but... My link Never happened last time :S Any idea what may have caused this? And its not leting me view my sub directories now.
February 15, 201016 yr Superb that worked... but... My link Never happened last time :S Any idea what may have caused this? And its not leting me view my sub directories now. I'm not sure why yours wasn't working, never tried anything hard written like that. I'll explain how the example I did for you works if that helps. RewriteRule ^(.*)/(.*)$ ./index.php?$1=$2 [NC] # ^ asserts position at start of string # $ asserts position at end of search string # ( ) - Everything inside is captured to a back refernce, in order. # ie. First ( ) = $1, Second ( ) = $2 and so on.. # .* matches any char (except newline) 0 or more times # ./ means current directory (Saves you hardcoding full URL & avoid other issues) # $1 & $2 spit out captures # [NC] No case/Case insensative matching Dave
February 15, 201016 yr Author thanks for the explanation, makes it easier to understand. your example worked, but when the site loaded, no images were displayed and any subdirectory i tried going to wouldn't work and kept redirecting me to the homepage. I'll keep having a play around with it.
February 16, 201016 yr thanks for the explanation, makes it easier to understand. your example worked, but when the site loaded, no images were displayed and any subdirectory i tried going to wouldn't work and kept redirecting me to the homepage. I'll keep having a play around with it. Ah.. this should fix it RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)$ ./index.php?$1=$2 [NC] #RewriteCond %{REQUEST_FILENAME} !-d #Doesn't serve index.php for a real directory #RewriteCond %{REQUEST_FILENAME} !-f #Doesn't serve index.php for a file that already exists on server
February 17, 201016 yr I've noticed images still not working on your site, this will finally fix it! Add a / infront of your image src /img/twitter.gif It works, I just tried it with firebug.
February 17, 201016 yr Author I've noticed images still not working on your site, this will finally fix it! Add a / infront of your image src /img/twitter.gif It works, I just tried it with firebug. PERFECT, Owe you one mate Should realised that from my portfolio page really... oh well ive learnt something, cheers buddy
Create an account or sign in to comment