301将.html中的所有页面和帖子网址重定向到/

时间:2017-09-24 13:35:21

标签: wordpress .htaccess redirect

我有一个当前网站,所有网址都以.html结尾。

我创建了一个新网站,而且网址几乎相同,但没有.html。

我一直在尝试在我的.htaccess文件中找到的代码,而且大多数代码都会导致内部服务器错误。

DB::connection()->enableQueryLog();

DB::table('products')
        ->leftJoin('product_locations', 'products.id', '=', 'product_locations.productId')
        ->select(DB::raw('IF(product_locations.id is not null,concat(product_locations.id,"-","M"),concat(products.id,"-","N")) as id'), DB::raw('IF(product_locations.id is not null,1,0) as multilocation'), 'products.productName', 'products.productName as text', 'product_locations.productLocationName', 'product_locations.binLocationName', 'product_locations.unitCost', 'product_locations.amount')
        ->orderBy('products.productName')
        ->distinct()
        ->get();

dd(DB::getQueryLog())

我当前的htacces文件代码是:

http://example.com/page1.html to http://example.com/page1/
http://example.com/page1/page2.html to http://example.com/page1/page2/

1 个答案:

答案 0 :(得分:0)

您可以安装Simple 301 Redirect插件并尝试在下面设置如下图片。刚刚在我的实际网站上进行了测试,它正在运行你想要的。

请记住,您也选中了Use wildcards?复选框。

enter image description here

相关问题