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

  • Home
  • SEARCH
  • 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 3438710
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:13:14+00:00 2026-05-18T08:13:14+00:00

If a user requests any .php file on my webserver I want his request

  • 0

If a user requests any .php file on my webserver I want his request (e.g. he requested mysite.com/testfile.php) to be handled by index.php

In index.php I use $_SERVER[‘REQUEST_URI’] to see which page the user wants to see (e.g. /testfile.php), so the index.php can generate the appropriate html-code. Notice that testfile.php doesn’t need to exist.

My problem is that I always get a redirect 302 to / when I try to request testfile.php (as a result $_SERVER[‘REQUEST_URI’] is /). But what I want is a 200 OK for testfile.php and that index.php generates the right html-code for this.

This is a snippet from my buggy nginx.conf:

 server {
 [...]

   root /home/test;

   # When I go to mysite.com redirect my to mysite.com/
   location = / {
   index index.php;
   }

   # For any php file request: let index.php handle the request
   location ~ \.(php)$ {
   include fastcgi_params;
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_param  SCRIPT_FILENAME  /home/test/index.php;
   }
 }

Anyone can help me out?
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-05-18T08:13:15+00:00Added an answer on May 18, 2026 at 8:13 am

    If the files never exist you can do this:

    try_files $uri $uri/ /index.php
    

    you can also rewrite the request like this:

    location / {
      rewrite ^.*$ /index.php last;
    }
    

    in both cases you should be able to read the original request with PATH_INFO or REQUEST_URI.

    Have a look at these links for some more suggestions: http://drupal.org/node/110224, http://michaelshadle.com/2010/08/20/front-controller-patterns-and-nginx/, Zend Framework on nginx

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

Sidebar

Related Questions

If a user requests a large file from an Apache web server, but cancels
I want to create a program that requests from the user 10 grades and
I want to check the login status of a user through an ajax request.
I want to capture the HTTP request header fields, primarily the Referer and User-Agent,
When a user request comes in, I can use Context.Request.UserHostAddress to get the user's
Let's say we're tracking the end-user IP for a web service: ip = Request.ServerVariables(HTTP_X_FORWARDED_FOR)
I have a PHP file that gets HTML from Memcached and serves it to
I have a flash application which uses a single php file to retrieve records
I have a PHP script that tests is the user is logged in, for
I have a file that takes a variable from the user then prints something,

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.