Solved

Redirect a file in nginx

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

728 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