Php .htaccess在忽略扩展名后重定向到文件夹
我的要求是URL应重定向如下所述 ==> ==> 在上面的示例中,page1/page2是根目录中的文件夹,应该从page1.html或page2.html重定向 任何人都可以提供以下解决方案的解决方案或增强功能 我尝试使用以下语法Php .htaccess在忽略扩展名后重定向到文件夹,php,apache,.htaccess,mod-rewrite,http-redirect,Php,Apache,.htaccess,Mod Rewrite,Http Redirect,我的要求是URL应重定向如下所述 ==> ==> 在上面的示例中,page1/page2是根目录中的文件夹,应该从page1.html或page2.html重定向 任何人都可以提供以下解决方案的解决方案或增强功能 我尝试使用以下语法 Redirect permanent http://mysite.com/page1.html http://mysite.com/page1 尝试: 您需要使用_REQUEST变量 RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/
Redirect permanent http://mysite.com/page1.html http://mysite.com/page1
尝试:
您需要使用_REQUEST变量
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+([^.]+)\.html[^\s?] [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+([^.]+)\.html[^\s?] [NC]
RewriteRule ^ /%1? [R=301,L]