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 6843149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:12:39+00:00 2026-05-27T00:12:39+00:00

Ok this maybe sound like the worst question on stackoverflow but here it is.

  • 0

Ok this maybe sound like the worst question on stackoverflow but here it is.

In a folder offers I have those files:

product.php
category.php

To display a product I type domain.com/offers/product.php?id=1 and
to display a category, I type domain.com/offers/category.php?id=1

Because this url looks ugly I rewrite for example the product.php using .htaccess

RewriteEngine On
RewriteRule ^([a-z0-9]+)?$ product.php?id=$1 [NC,L]

and this gives me a domain.com/offers/1

Because product.php and category.php are in the same folder and both gets a numeric variable, that means it will not execute correctly.

So a possible way is to have a slug for category.php and keep the id for product.php and then write some code for it.

My question is, is this the only way ?

Update
I didn’t tried it but what if I have the one as product.php?pid=1 and the other category.php?cid=1 ?

  • 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-27T00:12:39+00:00Added an answer on May 27, 2026 at 12:12 am

    You will need to differentiate them in the URL. This scheme would make the URLs into:

    example.com/offers/category/1
    example.com/offers/product/99
    

    Done via:

    RewriteEngine On
    RewriteRule ^offers/(product|category)/([a-z0-9]+)?$ $1.php?id=$2 [NC,L,QSA]
    

    The first group (product|category) captures the destination script, which is translated to $1.php. The second group is translated to to the associated id.

    Update

    You don’t have to have them appear as separate directories /products, /categories but you do have to have some way of differentiating them. Instead you can place a p or c at the start of the ID number:

    example.com/offers/c1
    example.com/offers/p99
    

    Done via:

    RewriteEngine On
    RewriteRule ^offers/p([a-z0-9]+)?$ product.php?id=$1 [NC,L,QSA]
    RewriteRule ^offers/c([a-z0-9]+)?$ category.php?id=$1 [NC,L,QSA]
    

    Or you can expand them out to

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

Sidebar

Related Questions

Ok so this maybe a simple/silly question but I don't know so here goes:
This might sound like a trivial question to a lot of people, but since
This maybe a stupid question, but as I can not easily undo my change
I know this maybe a very basic question but I'm having a bit of
I know this maybe a basic question but I just can't seem to find
This question maybe a better fit on The Business of Software forum but despite
Maybe this is a dumb question, but is there any way to convert a
This might sound like an odd scenario, but I've got two forms on one
I know this might sound like something which is explained everywhere.. but I've been
This sounds like a noob question for me but I need to ask it.

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.