I have a database that has a url colomn like this-is-the-title.php
I want to active mod_rewrite here with:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ news.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ news.php?url=$1
But I have problem with .php extension. This rule works only with this-is-the-title not this-is-the-title.php . Is there any way to active mod rewrite with titles that have .php extension or I have to change titles?
Thanks in advance
Your rewriterule doesn’t allow the dot character… If you want
something.phpto match, use this:^([a-zA-Z0-9-/.]+)$I’ve also simplified the fact there could be a trailing slash: since the slash is already allowed, a trailing slash will match as well.
Don’t forget to add some rewriteconds to avoid rewriting existing directories or files:
Btw, Adding a php extension to rewritten URLs doesn’t make any sense and you should stick to clean URLs with no extension at all.
So you end up with somehting like this: