I'm using a very simple method to enable vanity URLS on my website and yet, i get a 500 server error.
I want to enable URLs like this : mysite.com/ben
instead of mysite.com/profile.php?id=2
Here's the code i'm using in my htaccess file:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC]
RewriteCond %{REQUEST_FILENAME} >""
RewriteRule ^([^\.]+)$ profile.php?username=$1 [L]</pre>
Here's the query at the top of profile.php:
$getName = explode("/",$_SERVER['REQUEST_URI']);
$result = query("SELECT * FROM users WHERE username='$getName[3]'");
if (count($result) == 0)
{
header ('Location:404.php');
}
Now, with this script I get a 500 server error on any page I try to access. In my Apache error log, I can see: RewriteRule: bad flag delimiters
What does this mean?
OK, this is going to sound kind of dumb, but looking at the link that you posted here: http://culttt.com/2011/11/16/how-to-make-vanity-urls-using-php-htaccess-and-mysql/
The
</pre>
at the end of their example will cause a 500 server error. And, not surprisingly, when I look at my error logs, it says:So remove the
</pre>
and change the>
to>
.