Portal Home > Knowledgebase > Articles Database > nginx rewrite help/question
nginx rewrite help/question
Posted by jahsh, 08-29-2012, 12:00 PM |
Hi,
We are trying to rewrite specific pages to specific directories and it isn't working properly. I was wondering if somebody could assist.
Here is an example of what we are trying to:
#1 This doesn't work when redirecting to a directory (/tech):
rewrite ^/tech/index.shtml$ http://www.site.com/tech/ permanent;
#2 This does work when redirecting to a specific file (index2.shtml)
rewrite ^/tech/index.shtml$ http://www.site.com/tech/index2.shtml permanent;
I want to know how we can do option #1. Any help is greatly appreciated it!
|
Posted by vpsshell_co_uk, 08-29-2012, 12:25 PM |
Hi,
This rewrite rule looks fine. I've tested it and it works:
|
Posted by jahsh, 08-29-2012, 12:36 PM |
Thanks for your fast reponse. Why doesn't it redirect in the browser though?
|
Posted by vpsshell_co_uk, 08-29-2012, 12:49 PM |
It does for me. Are you trying to access the following URL:
http://yourdomain.com/tech/index.shtml
I assume that the "s" in the file extension (*.shtml) is set on purpose?
|
Posted by jahsh, 08-29-2012, 12:52 PM |
Yes, it is .shtml and it doesn't redirect. When I go to http://yourdomain.com/tech/index.shtml in the browser, it stays as http://yourdomain.com/tech/index.shtml
|
Posted by vpsshell_co_uk, 08-29-2012, 12:57 PM |
Please make sure you are accessing the vHost (server block) where this rule is actually set and don't forget to reload Nginx to apply the changes.
|
Posted by jahsh, 08-29-2012, 01:53 PM |
I've reloaded nginx and these entries are located in the same place as many other rewrite rules with files names. The only difference is I'm trying to redirect /tech/index.shtml to just /tech/ and it won't redirect in the browser.
|
Posted by jahsh, 08-29-2012, 02:13 PM |
Nevermind, I got this figured out. It was working all along but the pages were being cached by the boost module for drupal. Thanks for the help!
|
Posted by vpsshell_co_uk, 08-29-2012, 02:38 PM |
I was just about to ask you to clear the browser cache . I'm glad that is solved now.
|
Add to Favourites Print this Article
Also Read