Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Regex 需要htaccess 301重定向模式_Regex_.htaccess_Http Status Code 301 - Fatal编程技术网

Regex 需要htaccess 301重定向模式

Regex 需要htaccess 301重定向模式,regex,.htaccess,http-status-code-301,Regex,.htaccess,Http Status Code 301,我需要创建一个htaccess 301重定向来重定向所有 www.mydomain.dk/40005/(其中40005可以是任何5位数字) 到 www.mydomain.dk 有人知道怎么做吗?在文档根目录的htaccess文件或vhost配置中: RedirectMatch 301 ^/[0-9]{5}/?$ / 或者,您也可以使用mod_rewrite: RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.dk$ [NC

我需要创建一个htaccess 301重定向来重定向所有

www.mydomain.dk/40005/(其中40005可以是任何5位数字) 到 www.mydomain.dk


有人知道怎么做吗?

在文档根目录的htaccess文件或vhost配置中:

RedirectMatch 301 ^/[0-9]{5}/?$ /
或者,您也可以使用mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.dk$ [NC]
RewriteRule ^/?[0-9]{5}/?$ / [L,R=301]
这很简单:

RewriteEngine On
RewriteRule ^[0-9]{5}/?$ / [QSA,L,R=301]
看一看