Php .htaccess重定向所有不以/foo开头的URL/
我想重定向我网站上所有不以/foo/开头的URL 例如:Php .htaccess重定向所有不以/foo开头的URL/,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我想重定向我网站上所有不以/foo/开头的URL 例如: /page.html -> /foo/page.html /foo1/page.html -> /foo/foo1/page.html 等等 事实上,我有: RewriteCond %{REQUEST_URI} !^/foo/ RewriteRule (.*) www.example.com/foo/$1 [QSA,L,R=301,NC] 但是我得到一个错误。从您的规则中删除www.example.com Rewrite
/page.html -> /foo/page.html
/foo1/page.html -> /foo/foo1/page.html
等等
事实上,我有:
RewriteCond %{REQUEST_URI} !^/foo/
RewriteRule (.*) www.example.com/foo/$1 [QSA,L,R=301,NC]
但是我得到一个错误。从您的规则中删除
www.example.com
RewriteRule(.*)/foo/$1[QSA,L,R=301,NC]