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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:00:36+00:00 2026-06-09T14:00:36+00:00

I am beginner in PHP and Apache. I am trying to use URL Rewriting

  • 0

I am beginner in PHP and Apache. I am trying to use URL Rewriting for my website, which can have following URIs.

1. http://localhost:8080/home
2. http://localhost:8080/dell

For the first URI, there is home.php file available and I edited .htaccess file with following rewrite rule.

RewriteRule ^([^\.]+)$ $1.php [NC]

Second URI is dynamic – means there is no dell.php available for it that could handle the request. So I wrote following RewriteCond.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ list.php?page=$1

So as a whole, my .htaccess file is

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^([^\.]+)$ $1.php [NC] [N]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ list.php?page=$1

So when I request localhost:8080/home, home.php is duly responded but when I request localhost:8080/dell, an error is responded

“The requested URL /dell.php was not found on this server.”

I think only first RewriteRule takes precedence and second one is not even read by Apache server. Changing order does not work either. My question here is what RewriteRule(s) should I use that could work in both case – PHP file exists & does not exist?

Thank you for your opinion and guidance.

Ritesh

  • 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-06-09T14:00:37+00:00Added an answer on June 9, 2026 at 2:00 pm

    You need to do a pre-emptive check against the %{REQUEST_FILENAME} with a .php after it to see if that exists before you try to rewrite it, otherwise URI’s like dell will get blindly rewritten:

    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^([^\.]+)$ $1.php [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm a beginner to php. i need to use php function which process some
I am a PHP beginner. I have developed a social networking website similar to
http://localhost:8888/test.php I typed in the above URL to navigate to a blank php file
I am a beginner level php programmer. I was trying to use the MVC
I'm a beginner in PHP trying implementing a simple registration system for a website.
I have executed a php script through GET request ex: http://localhost/example.php?id=9&name=exammple Now the example.php
I am trying to achieve the following: If a given URL is: http://example.com/abcdef then,
beginner PHP programmer here trying to use the mailchimp API... I keep getting this
I am little more than beginner PHP programmer and just recently started to use
PHP beginner working from a tutorial. I'm trying to do a simple upload from

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.