.htaccess将请求重定向到同一文件夹 [英] .htaccess redirecting requests to the same folder

查看:172
本文介绍了.htaccess将请求重定向到同一文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 .htaccess 不同的请求重定向到相同的文件夹。
例如:

I want to use .htaccessto redirect different requests to the same folder. E.g.:

domain.de/ordner1/fileX.html

domain.de/en/folder1/fileX.html

domain.de/it/casella1/fileX.html

所以每当有东西从 / ordner1 / / folder1 / / casella1 / 我想要$ code > .htaccess 从特定目录(例如 domain.de/all/fileX.html )中提取所请求的文件。

So whenever something is requested out of /ordner1/, /folder1/ or /casella1/ I want .htaccess to fetch the requested file out of a specific directory like domain.de/all/fileX.html.

我想防止重复的内容,但也保留所选语言的文件夹名称。
可以帮我解决这个问题吗?

I want to prevent duplicate content but also keep the foldernames in the selected language. Could you help me solve this problem?

推荐答案

尝试将以下内容添加到中。 htaccess 文件在您的网站的根目录。

Try adding the following to the .htaccess file in the root directory of your site.

RewriteEngine on
RewriteBase / 

#skip css, js etc
RewriteCond %{REQUEST_URI} !\.(css|js)[NC] 
#if request to ordner or folder1 or casella1, serve the file from all/
RewriteRule ^(ordner1|en/folder1|it/casella1)/(.+)$ all/$2 [L,NC] 

这篇关于.htaccess将请求重定向到同一文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆