[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

RewriteEngine Rules

I am trying to make some rewrite rules, but I am having issues with some of them. Can anyone help me out here?

These rules work:
RewriteRule ^blog$ blog.php [L]
RewriteRule ^blog/page/(.*)$ blog.php?page=$1 [L]
RewriteRule ^blog/category/(.*)/(.*)$ blog.php?cat=$1 [L]

But when I need to paginate that last rule, like this:
RewriteRule ^blog/category/(.*)/(.*)/page/(.*)$ blog.php?cat=$1&page=$3 [L]

It just doesn't. I guess it's because of the first rule having the (.*)...

Thanks!
0
ApOG
Asked:
ApOG
  • 3
1 Solution
 
DonConsolioCommented:
>RewriteRule ^blog$ blog.php [L]
>RewriteRule ^blog/page/(.*)$ blog.php?page=$1 [L]
>RewriteRule ^blog/category/(.*)/(.*)$ blog.php?cat=$1 [L]
for rule 3 try this (assuming there are no slashes required in $2)
RewriteRule ^blog/category/(.*)/([^/]*)$ blog.php?cat=$1 [L]
0
 
ApOGAuthor Commented:
Thanks DonConsolio..

I tried it, but with no luck.

This: http://www.domain.com/blog/category/3/categoryname/page/2 is exactly like using: http://www.domain.com/blog/category/3/categoryname

Thanks!
0
 
ApOGAuthor Commented:
Well I figured it out.

The 4th rule must be before the third rule. And that's it! :)
0
 
ApOGAuthor Commented:
This solved my issue.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now