Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6333771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:31:40+00:00 2026-05-24T18:31:40+00:00

I have a rewrite rule on apache2 in the .htaccess file that is working

  • 0

I have a rewrite rule on apache2 in the .htaccess file that is working fine for the posts.php page.

mysite.com/post.php?id_name=this-is-the-title-of-my-site 

becomes

mysite.com/this-is-the-title-of-my-site

I want to use the same rule for the cats.php page so that

mysite.com/cats.php?cat_label=articles

becomes

mysite.com/articles

I have used the same rule and changed the file name and the parameters but the rule for the cats.php page seems to fail and be overridden by the posts.php rule

I would prefer not to but I don’t mind changing the structure to become

mysite.com/cats/articles

This is the .htaccess file that I am using at the moment

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ post.php?id_name=$1 [L,QSA]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ cats.php?cat_label=$1 [L,QSA]

All help is truly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:31:41+00:00Added an answer on May 24, 2026 at 6:31 pm

    The flag [L] means “Last”, as in, when that rule is matched, it is the last rewrite rule tested. You need a way to distinguish the two types of redirects. Here’s two ways you might do that:

    (1) Have dashes in all of your post names, but not in your categories, so both of your given examples work as given:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^-]+)$ cats.php?cat_label=$1 [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ post.php?id_name=$1 [L,QSA]
    

    (2) Add a directory for the categories so that there isn’t any magical character stuff going on, which can lead to mistakes. You already confronted this possibility above. Here’s how it would look:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^cats/(.*)$ cats.php?cat_label=$1 [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ post.php?id_name=$1 [L,QSA]
    

    In both cases, we match the more specific versions first, flagging them as [L]ast. Then we have the broad, catchall at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an .htaccess file that's using several rewrite rules. These rules aren't working
I have this rewrite rule in my .htaccess file, but in PHP when I
I have this rewrite rule RewriteEngine On RewriteBase /location/ RewriteRule ^(.+)/?$ index.php?franchise=$1 Which is
I have a rewrite rule of the following form: RewriteRule ^foo/([a-zA-Z0-9]+)$ foo.php?arg=$1 [qsa,nc] It
I have a mod_rewrite rule that will send any subdomain requests to a php
I have the following rewrite rule rewrite ^/ab(.*)/(.*)$ /repo/ab$1/rtest/$2 break; When the request file
I have an htacess file for apache that isn't working properly. I have a
I have a RewriteRule in a .htaccess file that isn't doing anything. How do
Current versions of MediaWiki have the front page accessible via http://www.example.com/wiki/index.php/Main_Page Instead of the
I am trying to create a rewrite rule that accomplishes two things: Redirect (www.)?domain.com

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.