Hi, I know how to rewrite URLs like the following: mysite.com/post/post-1/ mysite.com/category/category-1/ using RewriteRule ^post/([a-z0-9-]+)/$ post.php?post=$1 RewriteRule ^category/([a-z0-9-]+)/$ category.php?category=$1 Code (markup): What I want to achieve is to remove "post" and "category" from the URLs and have the following: mysite.com/post-1/ mysite.com/category-1/ Is this possible with .htaccess or do I need to have some sort of PHP solution? Thanks for any ideas.
With plain .htaccess redirection/mod_rewrite , definitely NO. You would need some php solution for that trick, to which you can redirect all requests and then have your PHP script sort it out to either a category or a post. However, what might be a good in-between solution is to leave your categories the way they are, and have the posts with shorten url. For example: RewriteRule ^category/([a-z0-9-]+)/$ category.php?category=$1 RewriteRule ^([a-z0-9-]+)/$ post.php?post=$1 Code (markup): In that way your categories will remain in a form: mysite.com/category/category-1/ but your posts would be like you wished: mysite.com/post-1/ Just make sure to put the rules in your .htacess in order I wrote them, so the first one listed is your category rule, and then posts rule after that. Cheers.
Please use Mod Rewrite Generator from and it will help you to set up all types of .htaccess redirections and rewrites. [h=1][/h]
Thanks for the idea. Actually, I decided to use some folders as directories instead of dealing with such a PHP script that you mentioned. Maybe I try that route at another time. Sorry, it doesn't help at all.