Solved

Redirect a file in nginx

Posted on 2010-09-01
4
472 Views
Last Modified: 2012-05-10
i want to redirect www.site.com/page.html to look for the page in the folders ROOT/php/inc/page.html
this i want to be done in nginx

i have tried with
 rewrite  ^/page.html$ /php/inc/page.php break; .. but with no results

any ideas ?
regards
0
Comment
Question by:rares_dumitrescu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 33577375
Can you not just put something like:

<meta http-equiv="refresh" content="2;url=/php/inc/pack.php">

In the page.html, and just let the client handle it?
0
 

Author Comment

by:rares_dumitrescu
ID: 33577616
i don't want page.html to exist on the document root
0
 

Accepted Solution

by:
Korcan earned 250 total points
ID: 33583505
Its not redirect its Rewrite.


rewrite ^/page.html.*$ /php/inc/page.php last;

The arguments are depend on .htaccess's location.
If .htaccess is in /dir/ then the rule should probably be:

rewrite ^/dir/page.html.*$ /dir/php/inc/page.php last;
0
 
LVL 3

Assisted Solution

by:fernandomerces
fernandomerces earned 250 total points
ID: 33583541
Well, I never used Nginx, but remember that rewrite module works with regexp, so, the dot is a special character. I think you need to escape it:

rewrite  ^/page\.html$ /php/inc/page.php break;

Reference: http://wiki.nginx.org/NginxHttpRewriteModule

Regards,

Fernando
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
The viewer will learn how to dynamically set the form action using jQuery.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question