Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将.html文件重定向到子文件夹?_Html_.htaccess_Redirect_Mod Rewrite_Url Rewriting - Fatal编程技术网

如何将.html文件重定向到子文件夹?

如何将.html文件重定向到子文件夹?,html,.htaccess,redirect,mod-rewrite,url-rewriting,Html,.htaccess,Redirect,Mod Rewrite,Url Rewriting,我正在尝试使用html创建一个在线多语言简历。只是我找不到任何解决方案如何将“www.cv.com/cvfiles/index_en.html”url重定向到“www.cv.com/en/cvfiles/”?还有法语(index_fr.html)和德语(index_de.html) 我的简历网站的所有文件都可以在以下文件夹中找到:…/public_html/cvfiles/要将/xx/cvfiles/重写为/cvfiles/index_xx.html,必须首先捕获语言部分,然后将其附加到目标索引

我正在尝试使用html创建一个在线多语言简历。只是我找不到任何解决方案如何将“www.cv.com/cvfiles/index_en.html”url重定向到“www.cv.com/en/cvfiles/”?还有法语(index_fr.html)和德语(index_de.html)


我的简历网站的所有文件都可以在以下文件夹中找到:…/public_html/cvfiles/

要将
/xx/cvfiles/
重写为
/cvfiles/index_xx.html
,必须首先捕获语言部分,然后将其附加到目标索引

RewriteRule ^(..)/cvfiles/?$ /cvfiles/index_$1.html [L]
我把最后的斜杠改为可选的。如果您想强制使用斜杠,只需省略问号
,例如
^(..)/cvfiles/$


反过来重写,只需交换模式和替换即可

RewriteRule ^cvfiles/index_(..)\.html$ /$1/cvfiles/ [L]

所以你想从一个三种语言的网站改成一种语言和一个URL?是的!我可以在公共html/文件夹中使用一些小技巧,如make en/cvfiles/、fr/cvfiles/、de/cvfiles/folders,但需要大量复制这些文件。我想要并且需要保持根文件夹整洁。我找到了一个基于您提供的代码的解决方案(仅虚拟文件夹重写,我尝试先修复它。):RewriteRule ^en(.*)$index_en.html$1[QSA]此代码运行得很好,只是发现了一个非常奇怪的问题。当我访问我的简历www.cv.com/en url时,请正确加载index_en.html文件,其中包含根目录中的所有图像和样式。但是,当我在url(如www.cv.com/en/的末尾添加斜杠“/”时,页面可以加载index_en.html文件,而无需css和图像。您可以看到以下错误消息:在此服务器上找不到请求的url/index_en.htmlstyle/maincss.css。这可能是css和图像的相对url存在问题?嗯。。。为什么不用“/”斜杠工作?我不明白这个问题。什么意思?