我正在尝试重定向,如果没有使用htaccess
设置cookie,但我无法阻止重定向循环。
用于wordpress安装。
目前我的.htaccess
是:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} !^cookie_name[NC]
RewriteCond %{REQUEST_URI} !^/page_to_redirect/ [NC]
RewriteRule .* /page_to_redirect/ [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
我该怎么做?
答案 0 :(得分:0)
这对我有用 - 如果设置了cookie,请求不是文件或目录,请求将由 index.php 处理,否则将由 redirect.php ,应该可以设置cookie。
#define CGAL_LINKED_WITH_TBB
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <sys/times.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_data_structure_3<
CGAL::Triangulation_vertex_base_3<K>,
CGAL::Triangulation_cell_base_3<K>,
CGAL::Parallel_tag
> TDS;
typedef CGAL::Delaunay_triangulation_3<K,TDS> Triangulation;
typedef Triangulation::Cell_handle Cell_handle;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Locate_type Locate_type;
typedef Triangulation::Point Point;
void load_file(const char* filename, std::vector<Point>& points) {
FILE* f = fopen(filename,"r");
if(f == NULL) {
std::cerr << "Could not open file" << filename << std::endl;
exit(-1);
}
while(!feof(f)) {
double x,y,z;
int nb_read = fscanf(f,"%lf %lf %lf", &x, &y, &z);
if(nb_read == 3) {
points.push_back(Point(x,y,z));
}
}
std::cerr << "Loaded " << points.size() << " points" << std::endl;
fclose(f);
}
int main(int argc, char** argv) {
int num_grid_cells_per_axis=50;
if(argc != 2 && argc != 3) {
std::cerr << "Usage: " << argv[0] << " points_filename <num_grid_cells_per_axis>" << std::endl;
exit(-1);
}
if(argc == 3) {
num_grid_cells_per_axis = atoi(argv[2]);
std::cerr << "Using " << num_grid_cells_per_axis << " grid cells per axis" << std::endl;
}
std::vector<Point> pts;
load_file(argv[1],pts);
double xmin=1e30,ymin=1e30,zmin=1e30;
double xmax=-1e30,ymax=-1e30,zmax=-1e30;
for(size_t i=0; i<pts.size(); ++i) {
xmin = std::min(xmin, pts[i].x());
ymin = std::min(ymin, pts[i].y());
zmin = std::min(zmin, pts[i].z());
xmax = std::max(xmax, pts[i].x());
ymax = std::max(ymax, pts[i].y());
zmax = std::max(zmax, pts[i].z());
}
Triangulation::Lock_data_structure locks(
CGAL::Bbox_3(xmin, ymin, zmin, xmax, ymax, zmax),
num_grid_cells_per_axis
);
std::cerr << "Computing triangulation" << std::endl;
Triangulation T(pts.begin(), pts.end(), &locks);
std::cerr << "Computed triangulation" << std::endl;
// Uncomment to save the result (note: takes a lot of time
// since it uses a std::map to map CGAL internal pointers to
// indices).
// std::ofstream oFileT("output",std::ios::out);
// oFileT << T;
return 0;
}