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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:13:39+00:00 2026-05-17T17:13:39+00:00

Situation: I have a few hundred posts each belonging to a particular category. A]

  • 0

Situation:

I have a few hundred posts each belonging to a particular category.

A] Now when the user visits the home page, the content is irrespective of the category sorted by date.

http://www.example.com

He can navigate through different pages like:

Type 1: http://www.example.com/3 which corresponds to http://www.example.com/index.php?page=3

I can probably do this in mod_rewrite

B] The user can then decide to view by category like:

Type 2: http://www.example.com/Football which will correspond to

http://www.example.com/index.php?page=1&category=Football

He can then navigate through pages like:

Type 3: http://www.example.com/Football/5 which =>
http://www.example.com/index.php?page=5&category=Football

C] I have a directory called View with index.php in it. It only shows individual posts like:

Type 4: http://www.example.com/View/1312 => http://www.example.com/View/index.php?id=1312

Here is the mod_rewrite I do:

RewriteEngine on
RewriteRule ^View/([^/.]+)/?$ View/index.php?id=$1 [L]

Now here are the problems I have

In point C]: http://www.example.com/View/1312 works fine but http://www.example.com/1312/
(notice the trailing slash) breaks apart & gives weird results.
Q1) So how do I maintain consistency here?

Q2) Ideally I would want http://www.example.com/View/1514 to show a 404 Error if there is no post with id 1514, but now I have to manually take care of that in PHP code.

What is the right way of dealing with such dynamic urls? especially if the url is wrong.

Q3) how do I ensure that http://www.example.com & http://www.example.com/ both redirect to http://www.example.com/index.php?page=1; (mod_rewrite code would be helpful)

Please Note that there are only two index.php files. One in the root directory which does everything apart from showing individual posts which is taken care by a index.php in View directory. Is this a logical way of developing a website?

  • 1 1 Answer
  • 1 View
  • 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-17T17:13:40+00:00Added an answer on May 17, 2026 at 5:13 pm

    Try these rules:

    RewriteRule ^$ index.php?page=1 [L]
    RewriteRule ^([0-9]+)/?$ index.php?id=$1 [L]
    RewriteRule ^View/([0-9]+)/?$ View/index.php?id=$1 [L]
    RewriteRule ^([A-Za-z]+)/?$ index.php?category=$1&page=1 [L]
    RewriteRule ^([A-Za-z]+)/([0-9]+)/?$ index.php?category=$1&page=$2 [L]
    

    As for the other question: Yes, since Apache can map these requests to existing files, it responds with a success status code. Now if your application decides that the requested resource does not exist, you need to handle that within your application and send an appropriate status code.

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

Sidebar

Related Questions

I have a situation, wherein I have a few hundred records in a lookup
I have the following situation: I have a few hundred resources at my disposal
I have a situation where I need to generate a few similar anonymous delegates.
Situation: I have an index page which loads pages into it with ajax as
Situation I have a QList<QVariant> where each QVariant item should be a QList<QVariant> of
Situation I have a few single-responsibility Servlets that take a request, do their job,
Situation I have 5 Access DB files, each one has 10 tables, 40 queries
I have a situation where I have to a have a few different sized
I have a situation where I have quite a few generated functions, and would
The situation: I have a class library, called RT.Servers , containing a few resources

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.