Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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
.htaccess htaccess 301重定向到文件夹而不更改URL_.htaccess_Url Redirection - Fatal编程技术网

.htaccess htaccess 301重定向到文件夹而不更改URL

.htaccess htaccess 301重定向到文件夹而不更改URL,.htaccess,url-redirection,.htaccess,Url Redirection,我想将我的网站重定向到一个文件夹 Example from: www.mysite.com to: www.mysite.com/foldername Final URL after redirection: same as from 我的htaccess RewriteEngine on RewriteCond %{HTTP_HOST} ^mywebsite.ru\.com$ RewriteRule (.*) http://mywebsite.ru/$1 [R=301,L] RewriteR

我想将我的网站重定向到一个文件夹

Example
from: www.mysite.com
to: www.mysite.com/foldername
Final URL after redirection: same as from
我的htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.ru\.com$
RewriteRule (.*) http://mywebsite.ru/$1 [R=301,L]
RewriteRule ^$ foldername [L]
我不想在重定向后显示foldername。
如何重写它?感谢您的帮助。

您可以使用mod rewrite

RewriteEngine on
RewriteRule !foldername /foldername%{REQUEST_URI} [L]

这将在内部将您的站点从/重定向到/foldername

嗨,斯塔肯,我更新了上面的问题,插入了重定向代码。我尝试了你的建议,但foldername仍然显示它不起作用。我的意思是,我想将url重定向到一个文件夹。我的核心文件在一个名为“en”的子文件夹中,而不是在重定向时看到www.mywebsite.com/en,我想隐藏文件夹“en”。在这种情况下,starkeen的答案应该有效
RewriteEngine on
RewriteRule !foldername /foldername%{REQUEST_URI} [L]