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;
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
add a comment |
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
add a comment |
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
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
nginx
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
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.
add a comment |
The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.
add a comment |
The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.
The order of directives matters in nginx. Try moving the rewrite rules up to the top of the / location.
answered Mar 28 '13 at 16:14
cnstcnst
7,9786 gold badges36 silver badges56 bronze badges
7,9786 gold badges36 silver badges56 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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