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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:15:21+00:00 2026-06-15T16:15:21+00:00

Sorry for poor title. I am now using RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond

  • 0

Sorry for poor title.
I am now using

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Its works fine when using localhost/home
But my problem is when typing localhost/home.php it also works.I want to redirect when typing localhost/home.php to an error page that the requested page does not exist.

How could i do it with .htaccess or should i use php to redirect?

  • 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-15T16:15:22+00:00Added an answer on June 15, 2026 at 4:15 pm

    When you request the URL with the ‘.php’ extension, none of your .htaccess conditions are met, so the server (Apache) just serves the request normally. That’s why it works.

    The easiest in my opinion is to add another rule before the previous one:

    RewriteCond %{REQUEST_URI} \.php$ # if it ends in .php
    # note we're using REQUEST_URI above to only match when
    # the URI ends in .php, not the requested file,
    # otherwise we would have a endless loop!
    RewriteRule ^(.*)$ /error_page.php # note the leading slash
    

    Add the [R] option to the RedirectRule if you want the browser to redirect (and I think you need to add a full path), eg:

    RewriteRule ^(.*)$ /path/error_page.php [R]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, sorry for my poor language. I'm using VC++ Express myself. Now I'm studying
Sorry for the poor title, can't think of a succinct way of putting this..
Sorry for the poor title,I'm new to OOP so I don't know what is
First, I am really sorry for my poor english. Now when I use Ext.List
at first sorry about my poor English. Now Im having a problem in closing
Sorry for the lame title, my descriptive skills are poor today. In a nutshell,
Sorry for the poor title guys, but I'm whooped. I have a table as
Sorry for the poor title, I don't really know what to call this. I
Sorry for the poor title, but I couldn't think of another way to describe
Sorry for the poor title. Take these cases: Case 1: a = true; if

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.