简体   繁体   English

使用 htaccess 更改 url 中的文件夹名称

[英]change folder name in url using htaccess

I want change the folder name on fly, using htaccess我想使用 htaccess 即时更改文件夹名称

this is actual url: http://dailycode.local:8384/home/View/dashboard/这是实际的 url: http://dailycode.local:8384/home/View/dashboard/

I want to see this url like this: http://dailycode.local:8384/en/v/dashboard/我想看到这个 url 像这样: http://dailycode.local:8384/en/v/dashboard/

change the: "home" -> en "view" -> v更改:“home”-> en“view”-> v

To 301 redirect all files in the direct to the new directory in .htaccess, try this:要 301 将直接中的所有文件重定向到 .htaccess 中的新目录,试试这个:

RewriteEngine On
RewriteRule ^old\ foldr/(.*) /newfolder/$1 [R=301,NC,L]

This should redirect all HTML pages, images, you name it.这应该重定向所有 HTML 页面,图像,你的名字。 It should also account for the space too.它也应该占空间。

You'll want to move all your files to the new folder location so when the redirect happens your end user doesn't receive a 404 error.您需要将所有文件移动到新文件夹位置,以便在重定向发生时您的最终用户不会收到 404 错误。

Also, you might possibly have to detail the white-space explicitly with '\s'此外,您可能必须使用 '\s' 明确地详细说明空白

RewriteEngine On
RewriteRule ^old\sfoldr/(.*) /newfolder/$1 [R=301,NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM