how to apply nginx rewrite from htaccessIn Nginx, how can I rewrite all http requests to https while maintaining sub-domain?Nginx: Rewrite rule for subfolderHow does try_files work?NGINX don't parse .php5 as .phpLaravel 4.1 on nginx routes error 404NginX + WordPress + SSL + non-www + W3TC vhost config file questionsnginx PHP files downloading instead of executingCodeIgniter nginx rewrite rules for i8ln URL'stry_files serving fall back before previous conditionHow to configure nginx to serve one site from two different document root and using different php depending on URL

Averting Real Women Don’t Wear Dresses

Is this the golf ball that Alan Shepard hit on the Moon?

Anagram Within an Anagram!

How can I check type T is among parameter pack Ts... in C++?

Is my Rep in Stack-Exchange Form?

Magnitude of vector quantities

C-152 carb heat on before landing in hot weather?

Layout of complex table

How often can a PC check with passive perception during a combat turn?

Pull-up sequence accumulator counter

Why aren't (poly-)cotton tents more popular?

Was "I have the farts, again" broadcast from the Moon to the whole world?

Should I tell my insurance company I have an unsecured loan for my new car?

Is there any set of 2-6 notes that doesn't have a chord name?

Going to get married soon, should I do it on Dec 31 or Jan 1?

Why does the A-4 Skyhawk sit nose-up when on ground?

Why does this fireplace work?

Why does the numerical solution of an ODE move away from an unstable equilibrium?

How to positively portray high and mighty characters?

Derivative of an algebraic power series in positive characteristic

How are monocytes larger than capillaries?

Zombie Diet, why humans

Should I hide continue button until tasks are completed?

How was film developed in the late 1920s?



how to apply nginx rewrite from htaccess


In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?Nginx: Rewrite rule for subfolderHow does try_files work?NGINX don't parse .php5 as .phpLaravel 4.1 on nginx routes error 404NginX + WordPress + SSL + non-www + W3TC vhost config file questionsnginx PHP files downloading instead of executingCodeIgniter nginx rewrite rules for i8ln URL'stry_files serving fall back before previous conditionHow to configure nginx to serve one site from two different document root and using different php depending on URL






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I installed ispconfig/nginx on ubuntu 12.10 following "perfect server" here:
http://www.howtoforge.com/forums/showthread.php?t=61141



I need to apply rewrite rules to nginx from a .haccess file with these contents:



RewriteRule ^(.)/(.)-video_(.*).html$ musicvideo.php?vid=$3



RewriteRule ^([^/])-video_(.).html$ watch.php?vid=$2



i used an online converter and got this output:



location / 
rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



Then I put the code in ./sites-available/default under server block and restarted nginx but I am getting error:



duplicate location "/" in /etc/nginx/sites-enabled/default:133
nginx: configuration file /etc/nginx/nginx.conf test failed


and If I put my rewrite rules within the existing Location:



location / 
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



then nothing happens! could someone please point out to me what I am doing wrong?










share|improve this question






























    0















    I installed ispconfig/nginx on ubuntu 12.10 following "perfect server" here:
    http://www.howtoforge.com/forums/showthread.php?t=61141



    I need to apply rewrite rules to nginx from a .haccess file with these contents:



    RewriteRule ^(.)/(.)-video_(.*).html$ musicvideo.php?vid=$3



    RewriteRule ^([^/])-video_(.).html$ watch.php?vid=$2



    i used an online converter and got this output:



    location / 
    rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

    rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



    Then I put the code in ./sites-available/default under server block and restarted nginx but I am getting error:



    duplicate location "/" in /etc/nginx/sites-enabled/default:133
    nginx: configuration file /etc/nginx/nginx.conf test failed


    and If I put my rewrite rules within the existing Location:



    location / 
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.html;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
    rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

    rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



    then nothing happens! could someone please point out to me what I am doing wrong?










    share|improve this question


























      0












      0








      0








      I installed ispconfig/nginx on ubuntu 12.10 following "perfect server" here:
      http://www.howtoforge.com/forums/showthread.php?t=61141



      I need to apply rewrite rules to nginx from a .haccess file with these contents:



      RewriteRule ^(.)/(.)-video_(.*).html$ musicvideo.php?vid=$3



      RewriteRule ^([^/])-video_(.).html$ watch.php?vid=$2



      i used an online converter and got this output:



      location / 
      rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

      rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



      Then I put the code in ./sites-available/default under server block and restarted nginx but I am getting error:



      duplicate location "/" in /etc/nginx/sites-enabled/default:133
      nginx: configuration file /etc/nginx/nginx.conf test failed


      and If I put my rewrite rules within the existing Location:



      location / 
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ /index.html;
      # Uncomment to enable naxsi on this location
      # include /etc/nginx/naxsi.rules
      rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

      rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



      then nothing happens! could someone please point out to me what I am doing wrong?










      share|improve this question
















      I installed ispconfig/nginx on ubuntu 12.10 following "perfect server" here:
      http://www.howtoforge.com/forums/showthread.php?t=61141



      I need to apply rewrite rules to nginx from a .haccess file with these contents:



      RewriteRule ^(.)/(.)-video_(.*).html$ musicvideo.php?vid=$3



      RewriteRule ^([^/])-video_(.).html$ watch.php?vid=$2



      i used an online converter and got this output:



      location / 
      rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

      rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



      Then I put the code in ./sites-available/default under server block and restarted nginx but I am getting error:



      duplicate location "/" in /etc/nginx/sites-enabled/default:133
      nginx: configuration file /etc/nginx/nginx.conf test failed


      and If I put my rewrite rules within the existing Location:



      location / 
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ /index.html;
      # Uncomment to enable naxsi on this location
      # include /etc/nginx/naxsi.rules
      rewrite ^/(.*)/(.*)-video_(.*).html$ /musicvideo.php?vid=$3;

      rewrite ^/([^/]*)-video_(.*).html$ /watch.php?vid=$2;



      then nothing happens! could someone please point out to me what I am doing wrong?







      nginx






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 '13 at 8:57









      Jenny D

      24.6k12 gold badges62 silver badges97 bronze badges




      24.6k12 gold badges62 silver badges97 bronze badges










      asked Mar 27 '13 at 4:46









      UWM StUWM St

      12 bronze badges




      12 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          0














          The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "2"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f491694%2fhow-to-apply-nginx-rewrite-from-htaccess%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.






            share|improve this answer



























              0














              The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.






              share|improve this answer

























                0












                0








                0







                The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.






                share|improve this answer













                The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 '13 at 16:14









                cnstcnst

                7,9786 gold badges36 silver badges56 bronze badges




                7,9786 gold badges36 silver badges56 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f491694%2fhow-to-apply-nginx-rewrite-from-htaccess%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos