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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:38:35+00:00 2026-05-17T19:38:35+00:00

I have a basic Magento (PHP app, using index.php as the controller) setup on

  • 0

I have a basic Magento (PHP app, using index.php as the controller) setup on an Ubuntu server. I configured NGINX to use PHP-CGI to serve all PHP pages. While the site is working as expected, all the URLs are of the form:
http://domain.com/index.php/apparel/shoes.html

Is there a way to use the nginx rewrite setting so that I can have the URLs like this instead:
http://domain.com/apparel/shoes.html

Currently, this is what I have in the configuration file to handle page requests:

# catch rewritten and standard URLs
location ~* ^(/index.php)?(.*) {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root/index.php$1;
    fastcgi_read_timeout 600;
}

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-17T19:38:35+00:00Added an answer on May 17, 2026 at 7:38 pm

    I have some experience with nginx in this regard and have even written about it. So in a shameless act of self-promotion here is the result of my earlier research:
    http://www.magentocommerce.com/boards/viewreply/211050/


    Six years on and the above link is dead. Also my nginx configs are more mature. The following starts by blocking all files and only allowing those which are explicitly public. All other requests are rewritten to index.php. If you want to execute some other PHP file you must write your own exclusion. This is the safest way I can think of.

    /etc/nginx/magento_server:

    ##
    # Include from "server {}" block
    ##
    
    # 1M = one month
    expires 1M;
    # recommended for all content, regardless
    add_header X-Content-Type-Options "nosniff";
    
    ##
    # Front handler
    ##
    
    location / {
        # if is evil, except when it isn't
        if (-f $request_filename) {
            return 403;
        }
        rewrite ^ /index.php last;
    }
    location = /index.php {
        expires off;
        add_header X-Content-Type-Options    "nosniff";
        add_header X-Xss-Protection          "1; mode=block";
    
        # "php" must be defined as an upstream
        fastcgi_pass                         php;
        include                              fastcgi_params;
        fastcgi_param SCRIPT_FILENAME        $document_root/index.php;
    
        uninitialized_variable_warn          off;
        fastcgi_param MAGE_RUN_CODE          $mage_run_code if_not_empty;
        fastcgi_param MAGE_RUN_TYPE          $mage_run_type if_not_empty;
        fastcgi_param MAGE_IS_DEVELOPER_MODE $mage_is_developer_mode if_not_empty;
        fastcgi_param APPLICATION_ENV        $application_env if_not_empty;
        # same as max_execution_time in .htaccess
        fastcgi_read_timeout                 18000s;
    }
    
    ##
    # Whitelist public static files
    #
    # avoid regex where possible
    ##
    
    location ^~ /media/ {
        # sometimes files are retrieved from database with get.php
        try_files $uri @mediaget;
    }
    # there is no way to call get.php directly
    location @mediaget {
        add_header X-Content-Type-Options    "nosniff";
        add_header X-Xss-Protection          "1; mode=block";
        fastcgi_pass                         php;
        include                              fastcgi_params;
        fastcgi_param SCRIPT_FILENAME        $document_root/get.php;
    }
    
    location ^~ /skin/ {
        # allowed with defaults
    }
    location ^~ /js/ {
        # allowed with defaults
    }
    
    # should not be accessed normally since real favicon is in /skin/frontend
    # however this is conventional
    location = /favicon.ico {
        # pretty sure that it exists but just in case...
        log_not_found off;
    }
    
    # specific exclusions, still no regex
    location = /media/.htaccess              { return 404; }
    location ^~ /media/customer/             { return 404; }
    location ^~ /media/downloadable/         { return 404; }
    
    ##
    # Error handling
    ##
    
    # possibly change this to Magento's no-route path
    error_page 404 /errors/404.php;
    location = /errors/404.php {
        fastcgi_pass                         php;
        include                              fastcgi_params;
        fastcgi_param SCRIPT_FILENAME        $document_root/errors/404.php;
    }
    
    # used when site is in maintenance mode
    error_page 500 503 /errors/503.php;
    location = /errors/503.php {
        fastcgi_pass                         php;
        include                              fastcgi_params;
        fastcgi_param SCRIPT_FILENAME        $document_root/errors/503.php;
    }
    
    # empty blocks allow serving without modification
    # ideals for gzip and mime-type are already loaded
    location ^~ /errors/default/css/         { }
    location ^~ /errors/default/images/      { }
    location ^~ /errors/enterprise/css/      { }
    location ^~ /errors/enterprise/images/   { }
    

    /etc/nginx/conf.d/php.conf:

    upstream php {
        server 127.0.0.1:9000;
        # add more PHP-FPM processes here if you have them, or maybe a unix socket
    }
    

    Each store then has it’s own server block similar to this:

    /etc/nginx/sites-enabled/yoursite.com:

    server {
        server_name        yoursite.com;
        root               /var/www;
        include            magento_server;
        set $mage_run_code "default";
        set $mage_run_type "website";
    }
    

    And since .htaccess files are ignored (because this is not Apache) it helps to put .user.ini in each web root:

    /var/www/.user.ini

    max_execution_time=600
    memory_limit=256M
    session.auto_start=off
    session.gc_maxlifetime=31536000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic app using the ASP.NET membership provider. By default, you can
Currently, i have basic C++ and PHP skills. But, i want to switch to
I have a basic ajax application, which will not work, instead the php code
I have Basic Authorization mechanism on the server for WSDL/SOAP. How I can send
I have a basic form with controls that are databound to an object implementing
I have a basic understanding of mock and fake objects, but I'm not sure
I have a basic CRUD form that uses PageMethods to update the user details,
I have a basic model in which i have specified some of the fields
I have a basic ActiveRecord model in which i have two fields that i
I have a basic cs-major understanding of multi-threading but have never had to do

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.