Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 使用.htaccess将根文件夹(旧URL)的所有.php文件重定向到新文件夹_Apache_.htaccess_Mod Rewrite_Redirect_Url Redirection - Fatal编程技术网

Apache 使用.htaccess将根文件夹(旧URL)的所有.php文件重定向到新文件夹

Apache 使用.htaccess将根文件夹(旧URL)的所有.php文件重定向到新文件夹,apache,.htaccess,mod-rewrite,redirect,url-redirection,Apache,.htaccess,Mod Rewrite,Redirect,Url Redirection,我需要用.htaccess将根目录(旧URL)的所有.php文件重定向到已移动到新目录(新URL)的相同文件 e、 g: something.com/hasty.php,something.com/index.php 到 something.com/fold/hasty.php,something.com/fold/index.php 等等。此外: something.com/hector/hasty.php 到 something.com/fold/hector/hasty.php 请帮助,谢

我需要用.htaccess将根目录(旧URL)的所有
.php
文件重定向到已移动到新目录(新URL)的相同文件

e、 g:

something.com/hasty.php
something.com/index.php

something.com/fold/hasty.php
something.com/fold/index.php

等等。此外:

something.com/hector/hasty.php

something.com/fold/hector/hasty.php


请帮助,谢谢。

我认为正确的语法应该是:

Redirect 301 /handsome.php http://www.something.com/fold/handsome.php
Redirect 301 /index.php http://www.something.com/fold/index.php
Redirect 301 /hector/handsome.php http://www.something.com/fold/hector/handsome.php

.htaccess
文件中。进一步细节如下:.

使用htaccess重定向

RedirectMatch 301 something.com/handsome.php(.*) something.com/index.php$1

RedirectMatch 301 something.com/fold/handsome.php(.*) something.com/fold/index.php$1

RedirectMatch 301 something.com/hector/handsome.php(.*) something.com/fold/hector/handsome.php$1
您可以使用htaccess工具重定向

对不起,StackOverflow不是免费的编码服务。我们在这里帮助彼此解决特定的编程问题,因此也解决您的代码问题。我们不是来为你工作的。因此,从你自己开始,如果你不熟悉这些东西,那么就阅读一些教程、文档和一些示例。然后,如果您的代码遇到了一个特定的问题,那么是时候在这里提问并将您的代码与您的问题一起发布了。这已经解释清楚了,我建议你通读当地的旅游,看看这个网站是如何运作的:@Kitty:你有没有尝试过解决这个问题?嗨!记住,如果有任何答案解决了问题,请将以下答案之一标记为已接受!:)