Jump to content

.htaccess url rewrite issue

Recommended Posts

Hello everyone. I am having an issue with creating a rewrite for blog posts. Here is my .htaccess file.

It doesn't work as intended.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
RewriteRule ^views/blog/?$ page.php?slug=/blog/ [L]
RewriteRule ^views/blog/(.*)/?([0-9]*) page.php?page_slug=/blog/$1/$2 [L]

index.php file points to the index.php in the views folder.
Here is my folder stucture:

root folder >  views > blog > page.php

The structure I'm trying to create is the following for any blog posts to be:


Any help would be much appriciated.

Link to comment
Share on other sites

Doesn't quite answer my question.

The very first rule you have

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

says that anything that does not exist should go to index.php. If you want other things to apply first, other things that also do not exist, then those rules need to go before it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.