我需要所有子域重定向回根。
例)。 test.website.ca - > https://www.website.ca
fake1.website.ca - > https://www.website.ca
www.ggg.website.ca/ - > https://www.website.ca
等
以下是我尝试过的代码:
void cTextureManager::loadTextureMipmap(rapidxml::xml_node<>* textureNode){
std::string pathDif = textureNode->first_attribute("pathDif")->value();
std::string pathNrm = textureNode->first_attribute("pathNrm")->value();
std::string pathSpec = textureNode->first_attribute("pathSpec")->value();
FREE_IMAGE_FORMAT imgFormat = FreeImage_GetFileType(pathDif.c_str(), 0);//Get current format (assume all textures are the same format)
FIBITMAP* imagenDif = FreeImage_Load(imgFormat, pathDif.c_str());
imagenDif = FreeImage_ConvertTo32Bits(imagenDif);
FIBITMAP* imagenNrm = FreeImage_Load(imgFormat, pathNrm.c_str());
imagenNrm = FreeImage_ConvertTo32Bits(imagenNrm);
FIBITMAP* imagenSpec = FreeImage_Load(imgFormat, pathSpec.c_str());
imagenSpec = FreeImage_ConvertTo32Bits(imagenSpec);
int width = FreeImage_GetWidth(imagenDif); // Assume images are the same size..
int height = FreeImage_GetHeight(imagenDif);
GLubyte* textureDif = new GLubyte[4 * width*height];
GLubyte* textureNrm = new GLubyte[4 * width*height];
GLubyte* textureSpec = new GLubyte[4 * width*height];
char* pixelsDif = (char*)FreeImage_GetBits(imagenDif);
char* pixelsNrm = (char*)FreeImage_GetBits(imagenNrm);
char* pixelsSpec = (char*)FreeImage_GetBits(imagenSpec);
//FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
for (int j = 0; j<width*height; j++) {
textureDif[j * 4 + 0] = pixelsDif[j * 4 + 2];
textureDif[j * 4 + 1] = pixelsDif[j * 4 + 1];
textureDif[j * 4 + 2] = pixelsDif[j * 4 + 0];
textureDif[j * 4 + 3] = pixelsDif[j * 4 + 3];
textureNrm[j * 4 + 0] = pixelsNrm[j * 4 + 2];
textureNrm[j * 4 + 1] = pixelsNrm[j * 4 + 1];
textureNrm[j * 4 + 2] = pixelsNrm[j * 4 + 0];
textureNrm[j * 4 + 3] = pixelsNrm[j * 4 + 3];
textureSpec[j * 4 + 0] = pixelsSpec[j * 4 + 2];
textureSpec[j * 4 + 1] = pixelsSpec[j * 4 + 1];
textureSpec[j * 4 + 2] = pixelsSpec[j * 4 + 0];
textureSpec[j * 4 + 3] = pixelsSpec[j * 4 + 3];
}
int tempMipmapLevel = gCurrentMipmapLevel;
std::string name = textureNode->first_attribute("name")->value();
gMap_TextureNameToMipmapLevel[name] = tempMipmapLevel;
gCurrentMipmapLevel+= 3;
// Assume the texture is already bound to the GL_TEXTURE_2D target
glTexSubImage2D(GL_TEXTURE_2D, // 2D texture
0, // Level 0
(1024 * tempMipmapLevel), (1024 * tempMipmapLevel), // Offset 0, 0
1024, 1024, // 1024 x 1024 texels
GL_RGBA, // Four channel data
GL_UNSIGNED_BYTE, // Floating point data
(GLvoid*)textureDif); // Pointer to data
delete [] textureDif;
// Assume the texture is already bound to the GL_TEXTURE_2D target
glTexSubImage2D(GL_TEXTURE_2D, // 2D texture
0,
1024 * (tempMipmapLevel+1), 1024 * (tempMipmapLevel+1),
1024, 1024,
GL_RGBA,
GL_UNSIGNED_BYTE,
(GLvoid*)textureNrm);
delete[] textureNrm;
// Assume the texture is already bound to the GL_TEXTURE_2D target
glTexSubImage2D(GL_TEXTURE_2D, // 2D texture
0,
1024 * (tempMipmapLevel +2), 1024 * (tempMipmapLevel+2),
1024, 1024,
GL_RGBA,
GL_UNSIGNED_BYTE,
(GLvoid*)textureSpec);
delete[] textureSpec;
// int MaxTextureImageUnits;
// glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &MaxTextureImageUnits);
}
答案 0 :(得分:1)
您可以使用:
RewriteCond %{HTTP_HOST} !^www\.website\.ca$ [NC]
RewriteRule ^ https://www.website.ca%{REQUEST_URI} [NE,L,R=301]
没有uri,请使用相同的RewriteCond和:
RewriteRule ^ https://www.website.ca/ [L,R=301]