Nginx / Laravel配置从非index.php路由重定向

时间:2015-11-25 23:01:36

标签: laravel nginx

我刚刚部署了一个运行Laravel 5和nginx的新建网站,并努力设置我的nginx配置,以重定向一些旧网址 - 特别是那些扩展名为.php的网址。

我希望301重定向以下内容......

domain.com/foobar.php?id=123 -> domain.com/foobar/123

默认配置假定所有内容都从index.php运行,因此Laravel不会在foobar.php上触发。

我尝试添加以下重写规则,但它没有触发(我假设因为nginx没有侦听foobar.php请求?

rewrite ^/foobar.php(.*)$ /foobar/$1/ permanent;

我当前nginx配置的相关摘要......

server {
listen 443 ssl;
server_name domain.com;
root /home/domain.com/public;

index index.html index.htm index.php;

charset utf-8;

if ($request_method = GET ) {
    rewrite ^([^.]*[^/])$ $1/ permanent;
}

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/domain.com-error.log error;

error_page 404 /index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}
}

1 个答案:

答案 0 :(得分:0)

这应该有效:

$arg_{your_argument}

你可以获得像{your_argument}这样的任何论点。只需用实际参数名称替换#include <iostream> #include <bitset> #include <vector> #include <cmath> #include <fstream> #include <algorithm> using namespace std; class S_Rend { private: const bitset<8> beta=0xad; protected: bitset<8> alpha, lambda, gamma, omega; bitset<8> delta, eta, theta, ghost, spec; vector<long> cred; public: unsigned int integral; S_Rend() { delta=0x00; eta=0x00; theta=0x00; lambda=0x00; alpha=0x00; delta=0x00; }; ~S_Rend() { }; int s_render(ifstream&,ofstream&); int render(ifstream&,ofstream&); long s_nop(long t, int set); } n; /*+**- Project::Sailwinds -**+*/ long S_Rend::s_nop(long t,int set) { if (set) { integral=0; t=(long&)beta; } integral++; if (abs(round((t*1.618)*t-(integral+0.618))-1) <= 4294967296) return (abs(round((t*1.618)*t-(integral+0.618))-1)); else return (abs(round(sqrt(t))+(round(sqrt(t))*round(sqrt(integral))+1))); } int S_Rend::render(ifstream& in, ofstream& out) { long bn; long size=0; long t; if (!(in.is_open())) { return -1; } else { t=(long&)beta; for_each (std::istreambuf_iterator<char>(in), \ std::istreambuf_iterator<char>(), \ [&] (int x) { t=s_nop((long&)t,0); cred.push_back(t); alpha = (long&)cred[size]; delta = (long&)x; lambda ^= (alpha ^ delta); lambda ^= beta; lambda = (int&)lambda + 1; size++; }); printf("*"); } if (out.is_open()) { out << lambda << endl; out << size << endl; out << delta << endl; out << cred[size-1] << endl; } else { return -1; } in.close(); out.close(); return 0; } int S_Rend::s_render(ifstream& in, ofstream& out) { long i, n; long size; long t; long chk; in >> lambda; in >> size; in >> delta; in >> chk; t=(long&)beta; long bn=0; while (size-1>=bn) { t=s_nop((long&)t,0); cred.push_back(t); bn++; } if (cred[bn-1]==chk) cout << "\nValidity Pass... Success!" << endl; else { printf("\nValidity Pass...Fail! %u != %u",cred[cred.size()-1],chk); return 1; } cout << "\nWriting to Buffer..." << endl; vector<long> btrace; vector<long> ltr; bn=1; while (size-1>=bn) { ltr.push_back(1); btrace.push_back(1); ltr[0]=(long&)lambda; for (i=1;i<=btrace.size()-1;i++) { alpha = (long&)cred[size-bn]; ghost = (long&)btrace[i-1]; spec = (long&)ltr[bn] - 1; spec ^= (int&)beta; eta = spec | alpha; theta = spec & alpha; omega = spec | eta; gamma = spec & eta; if ((eta ^ gamma) == (theta ^ omega)) { printf("."); ghost = (eta ^ gamma); btrace[i-1] = (long&)ghost; } } bn++; } cout << "One more second..\n"; bn=0; while (bn<=btrace.size()-1) { bn++; delta = (long&)btrace[bn]; out << (const char)(long&)delta; } cout << "\nBuffer Written... Exiting..\n"; in.close(); out.close(); printf("*"); return 0; } int main() { string outfile = ""; string infile = ""; string DC = "1"; printf("Enter <C> or <D> to compress or decompress "); cin >> DC; printf("\nInput File: "); cin >> infile; ifstream in; in.open(infile.c_str(), std::ios::in | std::ios::binary); if (in.fail()) return -1; printf("\nOutput File: "); cin >> outfile; ofstream out; out.open(outfile.c_str(), std::ios::out); if (out.fail()) return -1; if ((DC=="c") || (DC=="C")) bool f=n.render(in, out); if ((DC=="d") || (DC=="D")) bool f=n.s_render(in, out); printf("\nProgram Execution Done."); n.~S_Rend(); return 0; } 即可。