Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other htaccess rewrite

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31503
    marcdefiant
    Participant

    Hey guys. I’m working on a site for myself that acts similar to wordpress.

    I have this file- posts.php, so to see each post the correct url will be: /posts/post-name (I use the following rewrite):
    RewriteRule ^post/([^/]+).php /post.php?$1 [NC]

    I also use a rewrite that allows me to leave out the .php extension.

    And this works fine.. But I wanted to make it more specific for each post i.e., /rant/post-name without making a rant.php file to do so. So i wrote this in my htaccess file:
    RewriteRule ^rant/([^/]+).php /post.php?$1 [NC]

    I get a 404, and the server doesn’t point towards the post.php file and it tries to load /rant/post-name (which doesnt actually exist) yet, the first code still works no problem…

    what am I doing wrong?

    #62612
    gno
    Member

    For .htaccess to work you need to be on a virtual host on an apache webserver with the AllowOverride configuration not set to None. :-)

    That is why it depends on hosts. .htaccess is not that weird ;-)

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.