简体   繁体   English

将URL从子文件夹重定向到根目录

[英]Redirect URL's from subfolder to root directory

All the files and subfolders that used to make up our old Flash website do not exist anymore and so the URL paths to all the pages are broken. 用于构成我们的旧Flash网站的所有文件和子文件夹不再存在,因此所有页面的URL路径均已损坏。

We could use help writing a Redirect for specific URL's as well as catch all rewrite rule for subfolders to redirect to the base domain / URL. 我们可以使用帮助为特定的URL编写重定向,以及捕获所有重写规则以使子文件夹重定向到基本域/ URL。

ex.) Specific URLs 例如。)特定的网址

example.com/home.html
example.com/info.html

Any file path or image/asset or page url within these subfolders redirect to root domain 这些子文件夹中的任何文件路径或图像/资产或页面URL都重定向到根域

example.com/flash/devices.html
example.com/flash/images/diagram.png

example.com/external/m2000.zip

New site is built with the latest version of Wordpress / Apache / PHP 新站点是使用最新版本的Wordpress / Apache / PHP构建的

EDIT 编辑

Current .htaccess code 当前的.htaccess代码

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


RewriteEngine on
RewriteCond %{REQUEST_URI} ^(/home.html|/info.html|/flash|/external)
RewriteRule (.*) http://qcmresearch.com [R=301,L]
</IfModule>

# END WordPress

The below .htaccess rewrite rule will work for you 以下.htaccess重写规则将为您工作

RewriteEngine on
RewriteCond %{REQUEST_URI} ^(/home.html|/info.html|/flash|/external)
RewriteRule (.*) http://example.com [R=301,L]

The online working code for the same is at .htaccess tester 相同的在线工作代码在.htaccess测试器中

The above code will 上面的代码将

Redirect specific url's like below to root domain 将特定网址重定向到根域

example.com/home.html

example.com/info.html

Redirect particular subfolders like below to room domain 将下面的特定子文件夹重定向到房间域

example.com/flash/devices.html
example.com/flash/images/diagram.png

example.com/external/m2000.zip

您可以使用“ https://wordpress.org/plugins/simple-301-redirects/ ”的简单301重定向插件。

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

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