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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:54:43+00:00 2026-06-04T05:54:43+00:00

I have two problems with Nginx I am hoping someone could help me with.

  • 0

I have two problems with Nginx I am hoping someone could help me with.

I have setup an aliased directory in my site called /wordpress/ and made it point to a file outside of my webroot now that’s all working fine and dandy until I try and browse the parent directory: /wordpress. It seems to want to redirect to *.x.co.uk (where x represents my domain name). Config to follow.

My other problem is that my Auth is not covering more than the root directory / despite being in the / caluse to catch anything that’s not /wordpress/ which is confusing me again. So I have to auth if I go to / but if I go /video I can get into my site without auth at all.

I am a bit new to Nginx so it’s prolly something stupid that I got confused on while reading the Wiki.

Anyone have any ideas? Here is my config for your viewing pleasure:

server {
        listen          80;
        server_name     _;
       root            /server_ws/the_stage/htdocs;
        access_log      /var/log/nginx/access.log;
        error_log       /var/log/nginx/error.log;

        error_page 404 /error/notfound;

        location /wordpress/ {
                alias /server_ws/wordpress/;
#               try_files $uri $uri/;
        }

   location ~* ^/wordpress/(.+).(jpg|jpeg|gif|css|png|js|ico|xml)$ {
           alias            /server_ws/wordpress/$1.$2;
           access_log      off;
           expires         30d;
   }

        location / {
                auth_basic "Restricted";
                auth_basic_user_file /etc/apache2/passwords;

                index   index.php;

                if ($host = 'x.co.uk') {
                        rewrite ^/(.*)$ http://www.x.co.uk/$1 permanent;
                }

                if (-f $request_filename) {
                        break;
                }

                if (!-e $request_filename) {
                        rewrite . /index.php last;
                }

                try_files $uri $uri/ /index.php;
        }

    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
            root            /server_ws/the_stage/htdocs;
            access_log      off;
            expires         30d;
    }

}

Here are some log entries for the auth. You can see in this one were a bot tried to access my robots.txt and fails due to auth:

2012/05/20 11:54:10 [error] 12059#0: *2008 no user/password was provided for basic authentication, client: 108.162.215.232, server: _, request: "GET /robots.txt HTTP/1.0", host: "www.x.co.uk"

But then I go to /video on my site and I get no errors but I get an access log of:

xxx.xxx.xxx.xxx - - [20/May/2012:12:51:35 +0000] "GET /video?cat=gaming&sort=upload_date HTTP/1.1" 301 185 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Here is the lastest log for /wordpress access:

xxx.xxx.xx.xxx - - [20/May/2012:13:01:08 +0000] "GET /wordpress HTTP/1.1" 301 185 "-" "Opera/9.80 (Windows NT 6.1; WOW64; U; Edition Campaign 21; en) Presto/2.10.229 Version/11.64"
  • 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-04T05:54:45+00:00Added an answer on June 4, 2026 at 5:54 am

    First question solution is changing location /wordpress/ block to that:

    location /wordpress {
        alias /server_ws/wordpress/;
        try_files $uri $uri/ /index.php?$args;
    }
    

    And please fix www rewrite, instead of if (which is evil) add this block:

    server {
        server_name x.co.uk;
        return 301 $scheme://www.x.co.uk$request_uri;
    }
    

    And, by the way, delete listen 80 from first server block, it’s implemented by default.

    UPD: rewrite ➡ return.

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

Sidebar

Related Questions

I have two problems I would greatly appreciate if someone could help me with.
I have two problems with INNO Setup? How do I check if an env.
I have two problems with the below code that I need help fixing: 1)
I have my program that can draw rectangles. I have two problems I can't
I have two cmake-related problems: first, I can't make it to find the includes
I have some localization problems in my webpage. There are basically two problems (that
We are having some problems deploying our WCF services into IIS7. We have two
I'm having some problems trying to perform a query. I have two tables, one
I have two problems related to image presentation in FancyBox2: Images are automatically applied
I have two problems with my website : http://test2.tamarawobben.nl Problem 1 : In IE9

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.