Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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
Php 如何在htaccess上重定向html文件?_Php_Regex_Apache_.htaccess_Redirect - Fatal编程技术网

Php 如何在htaccess上重定向html文件?

Php 如何在htaccess上重定向html文件?,php,regex,apache,.htaccess,redirect,Php,Regex,Apache,.htaccess,Redirect,我有以下网址: http://superawesomedomain.com/recently-created.html http://superawesomedomain.com/recently-created.html http://superawesomedomain.com/articles/recently-created.html http://superawesomedomain.com/surveys/0-6-months.html 我想将它们重定向到以下URL: http:/

我有以下网址:

http://superawesomedomain.com/recently-created.html
http://superawesomedomain.com/recently-created.html
http://superawesomedomain.com/articles/recently-created.html
http://superawesomedomain.com/surveys/0-6-months.html
我想将它们重定向到以下URL:

http://superawesomedomain.com/search_redirect?q=recently-created
http://superawesomedomain.com/search_redirect?q=recently-created
http://superawesomedomain.com/search_redirect?q=recently-created
http://superawesomedomain.com/search_redirect?q=0-6-months
我很难获取文件名(没有扩展名)并将其附加到我想要的url

我必须使用.htaccess进行重定向

我将非常感谢你的帮助。

这不管用吗

/recently-created.html /search_redirect?q=recently-created
/recently-created.html /search_redirect?q=recently-created
/articles/recently-created.html /search_redirect?q=recently-created
/surveys/0-6-months.html /search_redirect?q=0-6-months

您应该只需要在另一台服务器上使用if。

您可以在/root/.htaccess中使用以下重定向:

RedirectMatch 302 ^/(?:[^/.]*/)?([^.]+)\.html$ http://domain.com/search_redirect/?q=$1
这将重定向

/foo/bar.html

如果要使重定向永久化,请将状态代码302更改为301

参考文献:
-

您是否尝试过使用
重定向301
/bar.html
/search_redirect/?q=bar