Solved

Redirect a file in nginx

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now