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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:58:51+00:00 2026-06-17T23:58:51+00:00

so with apache i have a folder: www.domain.com/folder/folder1/index.php?word=blahblah and i want users who access

  • 0

so with apache i have a folder:

http://www.domain.com/folder/folder1/index.php?word=blahblah

and i want users who access http://www.domain.com/folder/folder1/blahblah to be redirected to the above URL without the url changing.

Thus i have the following .htaccess in the folder/folder1/ which works perfectly:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ index.php?word=$1

So i want to achieve the same functionality with nginx and i used two converters:
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ results in:

if (!-f $request_filename){
    set $rule_0 1$rule_0;
}
if (!-d $request_filename){
    set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
    rewrite ^/(.+)$ /index.php?word=$1;
}

and http://winginx.com/htaccess results in:

 if (!-e $request_filename){ rewrite ^(.+)$ /index.php?word=$1; }

now, i tried with both but neither works. I tried inserting them either in

location / {
}

or in

location /folder/folder1 {
}

or in

location ~ \.php$ {
}

in all locations i get a 404 error

nginx error reports either “primary script unknown while reading response header from upstream” or “no such file or directory”.

can someone enlighten me please ?

thanks in advance!

  • 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-17T23:58:52+00:00Added an answer on June 17, 2026 at 11:58 pm

    First, don’t use if. If is evil -> http://wiki.nginx.org/IfIsEvil

    You can accomplish this by using the following rewrite rule.

    rewrite ^/folder/folder1/(.*)$ /folder/folder1/index.php?word=$1 last;
    

    Place this rewrite rule just above you location / {} block

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

Sidebar

Related Questions

If I have site www.mysite.com and then I have folder apache/htdocs as public folder
I have 2 domain domain1.com domain2.net i want redirect domain1.com to domain2.net with path
I have a folder which php uploads to located in the directory above www
I have the domain example.com and the test.example.com running on apache server. For some
I'm having trouble with my Apache Web Server. I have a folder (htdocs\images) where
I have this Perl script sitting in the cgi-bin folder of my Apache server:
I have apache httpd that I want to proxy to two different tomcat servers.
Using CentOS5, I have Apache configured with the following directives. Alias /pscript/ /var/www/pscript/ <Directory
I have two folders for a particular web site. There is the main www.mysite.com
I get this problem when I visit my domain.com. I have compared this with

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.