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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:14:23+00:00 2026-06-11T17:14:23+00:00

I have this directive in my nginx virtual host file: try_files $uri $uri/ /profile.php?nickname=$uri&$args;

  • 0

I have this directive in my nginx virtual host file:

try_files $uri $uri/ /profile.php?nickname=$uri&$args;

It works ok, but I want to rewrite only 0-9a-z- characters so that users have nice profile addresses, for example:

http://www/mydomain.com/john

But nginx rewrites everything. For example, if I enter address:

http://www.mydomain.com/non-existing-holder/nonexisting-filename.html

instead of returning 404 error it rewrites everything.

Is there any way how to rewrite only 0-9-a-z- characters?

server {
    listen 80;
    server_name www.mydomain.com;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    root /var/www/mydomain;
    error_page 404 /4044.html;
    location / {
        index index.html index.htm index.php;
        try_files $uri $uri/ /profile.php?nickname=$uri&$args;
        rewrite ^/forum/([0-9-]+)/([0-9a-z-]+).html$ /forum.php?tid=$1&title=$2 last;
    }

    location ~ \.php$ {
        try_files  $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
  • 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-11T17:14:24+00:00Added an answer on June 11, 2026 at 5:14 pm

    You can try the following configuration.

    • Request for /testUSER would return a 404
    • Request for /forum/100/something.html would go to /forum.php?tid=100&title=something
    • Request for /nickname would go to /profile.php?nickname=nickname

    .

    location / {
        index index.html index.htm index.php;
        rewrite ^/([0-9a-z-]+)/?$ /profile.php?nickname=$1&$args last;
        try_files $uri $uri/ =404;
    }
    location /forum {
        rewrite ^/forum/([0-9-]+)/([0-9a-z-]+).html$ /forum.php?tid=$1&title=$2 last;
        alias /var/www/mydomain/forum;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following location directive in my nginx config file: server{ ... location
I have this preprocessor directive: #define INDEXES_PER_SECTOR BYTES_PER_SECTOR / 4 where BYTES_PER_SECTOR is declared
I have this C++ file (let's call it main.cpp ): #include <string> #include main.y.c
I have a PHP file I want to execute at the beginning of each
I have this XML file: <?xml version=1.0 encoding=UTF-8 standalone=no?> <games> <game id=123456 name=501> <player
I have this function in Python: def Rotate_Vector(vector, axis, direction): where vector is a
So, I have this simple code $('#info_name'+index).show(slide, {direction: right}, 1000, function(){ $('#info_info'+index).show('slide',{direction: up}, 1000);
I have a Wifi iPad and this compass actually knows the direction of north.
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in

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.