Okay I need my URLs to be short, sweet and SEO. I need them without the file extensions so as to be environment independent yet I want a trailing slash in case of content duplication. Below is what I have (does not work): #Trailing slashes RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://thinkingdays.co.cc/$1/ [L,R=301] #Hide the file extensions RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule (.*)/?$ $1.php Code (markup): So can anybody help me come up with code that works And can somebody please explain those symbols and stuff? I've been referencing to Apache's mod_rewrite guide to try to understand the symbols and stuff but I don't really understand their usage. Cheers!
I found a script that works, but don't understand how #No file extension RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^/]+)/$ $1.php #Trailing slash RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] Code (markup): See, from my analysis it's basically saying: 1) Enable the RewriteEngine 2) If %{REQUEST_FILENAME} is not a directory 3) And it is, if ".php" is added to the end, a file, 4) Then redirect to... ? What? Firstly when I enter homepage.com/index/ into the URL bar I don't get redirected anywhere. But I thought RewriteRule means to redirect? And what's this for "^([^/]+)/$" Thanks!