I'm making my personal CMS. I want to use in it cool (friendly) URLs. This is my .htaccess file code:
RewriteEngine on
RewriteBase /
DirectoryIndex index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z-_0-9_/]+)/?$ index.php?args=$1 [L]
I see that on Stack Overflow friendly URLs are also used. Today I tried to make an error on Stack Overflow. To (for example) this URL http://stackoverflow.com/questions/5469955/htaccess-url-rewrite-if-file-not-exists
. I added .php
. But I didn't see a 404 error. Our forum in a magic method deleted my postscript and redirected me back to correct site URL. How can I make the same in my CMS?
I tried to change this (RewriteRule ^([a-zA-Z-_0-9_/]+)/?$ index.php?args=$1 [L]
) line to (RewriteRule ^([a-zA-Z-_0-9_/]+)/([a-zA-Z-_0-9)$ index.php?args=$1 [L]
), but this isn't helpful and then I see 500 Internal Server Error
.