Hey Everyone, I have a small blog script that uses 2 files, index.php and post.php. The slug of each article is being controlled through the .htaccess file: RewriteEngine On RewriteRule ^/(.*) /post.php?slug=$1 The URL looks like this http://www.website.com/slug-goes-here However it doesn't work. I just get a 404 error. If I change the rewrite rule to: RewriteRule ^blog/(.*) /post.php?slug=$1 http://www.website.com/blog/slug-goes-here works great! I just don't want the word blog in there. Any idea how to make this work?? I am so lost! Thanks!!
Thanks, but I have tried that and it does not work at all, the whole site just goes offline. It says to many redirects. Any other ideas?
Maybe this? Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*)$ http://blog.domain.com/post.php?slug=$1 [R=301,L] Code (markup): http://kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules
For those looking, after what felt like 24 hours of trial and error I have found this and it works: RewriteRule ^([a-zA-Z0-9_-]+)$ post.php?slug=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ post.php?slug=$1 Code (markup): Thanks!
This is why I consider parsing the URI to turn it into GETDATA to be ... well... a REALLY stupid way of doing things. I like to use a whitelist of files to serve normally instead, and route EVERY other request to a single index.php Of course if you've got sloppy multiple entry points (like post.php, login.php, etc, etc) that the user can call directly, that can be a bit of a fight to switch it around.