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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:58:19+00:00 2026-05-17T00:58:19+00:00

I am updating a php app, which currently does not use url rewriting. The

  • 0

I am updating a php app, which currently does not use url rewriting. The aim is to hide file extensions. The general structure of the website is as follows

root/
  index.php
  login.php
  page1.php
  page2.php
  page3.php
  page4.php
  page5.php
  page6.php
  page7.php
  page8.php
subfolder/
  index.php
  validpage.php
images/
css/

The subfolder folder in the above structure is unique in that it is the only subfolder containing php files.All of the other files are in the root folder.

I have been through these questions Mod Rewrite and PHP and Mod-Rewrite or PHP router? and mod_rewrite, php and the .htaccess file

Updated htaccess. thanks to @thomasmalt

RewriteEngine on
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -l 
RewriteRule ^.*$ - [NC,L]


# only rewrite if the requested file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-s 

# add .php to the url     
RewriteRule ^(.*)$ $1.php

Problem now is I get a 500 instead of a 404 error, when I try to access a non existent page like localhost/inex.php. The Apache error log gives me the following errors. (I accessed localhost/index which loaded the contents of index.php , followed by which I loaded localhost/inex which gave me a 500 error.)

[Sat Sep 25 14:44:26 2010] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/index
[Sat Sep 25 14:44:36 2010] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Update: found the answer to my question here. The question is resolved.

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

    I’m not totally sure what you’re trying to achieve, and i suspect, no disrespect intended, that you need to understand both mod_rewrite, and the way the webserver and php parses and executes files. I’m not sure how to answer without shooting over or under your level of understanding, but I’ll try.

    I can tell you what you’re current .htaccess is doing: (pseudocode)

    if REQUEST_FILENAME does not exist then
        rewrite request to /index.php/<the request>
    

    Since index.php is your php script that is executed and everything put in $1 is ignored.
    That’s why index.php is executed whatever you do.

    What you could try to put in your .htaccess is this:

    RewriteCond %{REQUEST_FILENAME} !-s 
    RewriteRule ^(.*)$ $1.php
    

    That should take the request and try to append .php to the end of it. I haven’t tested it unfortunately, but you should give it a try. The result should be something like this:

    if request is "/news/article" 
        translate it to "/news/article.php"
    

    And you should read the mod_rewrite documentation twice a day for a month, and buy the O’Reilly book about Regular Expressions.

    And if you have administrator access to the development server you should look into

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

Sidebar

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.