htaccess的子目录的URL根

编程入门 行业动态 更新时间:2024-10-22 20:38:33
本文介绍了htaccess的子目录的URL根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在一个子目录中的所有文件重定向到新的根URL。

旧网址是

www.domain/subdirectory/filename-here.html

新位置

www.domain/filename.here.html

旧网址列在谷歌已经和需要某种重定向这些的。 我敢肯定,htaccess是要走的路在这里,但不确定的解决方案。

解决方案

RewriteEngine叙述上 重写规则%{REQUEST_URI} ^ /子目录/.* 重写规则子目录/(.*)$ / $ 1 [R = 301,L]

这里测试在。如果这是行不通的 - 添加屏蔽到 [^ /] 这样: [^ \ /]

I want to redirect all files in a subdirectory to their new root URL.

Old URLS are

www.domain/subdirectory/filename-here.html

New location is

www.domain/filename.here.html

Old URLs are listed in Google already and need some sort of redirect for these. I'm sure htaccess is the way to go here, but unsure of the solution.

解决方案

RewriteEngine on RewriteRule %{REQUEST_URI} ^/subdirectory/.* RewriteRule subdirectory/(.*)$ /$1 [R=301,L]

Tested on here. If it would not work - add shielding to [^/] in this way: [^\/]

更多推荐

htaccess的子目录的URL根

本文发布于:2023-11-01 20:19:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550313.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子目录   htaccess   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!