Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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 在1个子目录中重写多个URL_Apache_.htaccess_Mod Rewrite_Redirect_Rewrite - Fatal编程技术网

Apache 在1个子目录中重写多个URL

Apache 在1个子目录中重写多个URL,apache,.htaccess,mod-rewrite,redirect,rewrite,Apache,.htaccess,Mod Rewrite,Redirect,Rewrite,我想将多个页面重定向到新的子目录 /testme/page1将重定向到/testmenew/page1 /testme/page2将重定向到/testmenew/page2 等等 现在,上面的重定向只是指向主页。将此规则作为根目录中的第一条规则。htaccess: RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?url\.com$ RewriteRule ^testme(/.*)?$ /testmenew$1 [R=301,L,NC] 最

我想将多个页面重定向到新的子目录

/testme/page1将重定向到/testmenew/page1 /testme/page2将重定向到/testmenew/page2 等等


现在,上面的重定向只是指向主页。

将此规则作为根目录中的第一条规则。htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?url\.com$
RewriteRule ^testme(/.*)?$ /testmenew$1 [R=301,L,NC]

最好在新浏览器中测试,以避免旧浏览器缓存。

再次感谢!是否需要NC?我省略了它。不需要NC,它只用于忽略大小写比较。
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?url\.com$
RewriteRule ^testme(/.*)?$ /testmenew$1 [R=301,L,NC]