Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache 使用htacess将一条路径重定向到另一条保留旧路径的路径';文件名_Apache_.htaccess_Mod Rewrite_Url Redirection - Fatal编程技术网

Apache 使用htacess将一条路径重定向到另一条保留旧路径的路径';文件名

Apache 使用htacess将一条路径重定向到另一条保留旧路径的路径';文件名,apache,.htaccess,mod-rewrite,url-redirection,Apache,.htaccess,Mod Rewrite,Url Redirection,我想重定向一个URL:www.example.com/folder1/folder2/about.php 另一个URL地址:www.example.com/folderA/about.php 使用.htacess可以吗?我正在使用Wordpress。是的,这是可能的。在Wordpress规则之前尝试此规则 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Your redirect

我想重定向一个URL:
www.example.com/folder1/folder2/about.php

另一个URL地址:
www.example.com/folderA/about.php


使用.htacess可以吗?我正在使用Wordpress。

是的,这是可能的。在Wordpress规则之前尝试此规则

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Your redirect rules

RewriteCond %{REQUEST_URI} ^\/folder1\/folder2\/([^\/]+)$ [NC]
RewriteRule ^ http://%{HTTP_HOST}/folderA/%1 [R=301,NC,L]

# Your redirect rules

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
#开始WordPress
重新启动发动机
重写基/
#你的重定向规则
RewriteCond%{REQUEST_URI}^\/folder1\/folder2\/([^\/]+)$[NC]
重写规则^http://%{http_HOST}/folderA/%1[R=301,NC,L]
#你的重定向规则
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress