Solved

Redirect a file in nginx

Posted on 2010-09-01
4
471 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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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