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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:51:36+00:00 2026-06-14T18:51:36+00:00

I have a .htaccess file that essentially removes the file extension in the web

  • 0

I have a .htaccess file that essentially “removes” the file extension in the web browser (from example.php to example). Here’s the code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]

Basically, if the file (about) isn’t found, it adds the .php extension (about.php). I want to (if the file still isn’t found) redirect the user to 404.php. So if the user loads /page1, and page1.php doesn’t exist, it redirects to the 404 page. I added this code to the .htaccess:

ErrorDocument 404 /404.php

On it’s own, this code will redirect to the 404 page. But when I have the entire code…

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]

ErrorDocument 404 /CWTC/404.php

…it just shows a “500 Internal Server Error”.

Does anyone know what I’m doing wrong?

Thanks!

  • 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-14T18:51:38+00:00Added an answer on June 14, 2026 at 6:51 pm

    This has solved my problem:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php [L,QSA]
    
    ErrorDocument 404 /404.php
    

    Thanks!

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

Sidebar

Related Questions

I have a rewrite in my htaccess file that removes index.php from the url
Ok, so I have this .htaccess file that contains this <IfModule mod_rewrite.c> RewriteEngine On
I have created an .htaccess files that will prevent anyone from accessing a file
I have a link which looks like that: www.domain.com/file.php I want to create .htaccess
I have such .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php
I have the following in my htaccess file: RewriteEngine On RewriteRule ^(.*)$ rewrite.php?data=$1 [L,QSA]
I have a .htaccess file which arranges that all requests go through index.php. Now
I have the following htaccess file: RewriteEngine On RewriteRule ^([^/]*)$ /bio.php?bio=$1 [L] I need
I have a working .htaccess file that changes .php to .html. How can I
I have a .htaccess file that looks like this: SetEnv APPLICATION_ENV development RewriteEngine On

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.