2017-04-04 54 views
1

我想创建一种通配符重定向到一个新的url。重定向url的htaccess部分

我替换了一个特定的部分,应该重定向。

包含所有的URL以下/computers/notebooks-laptops/

应重定向到/computers/laptops/

所以下面的网址

https://www.example.com/computers/notebooks-laptops/product1 

应该变成:

https://www.example.com/computers/laptops/product1 

我怎样才能做到这一点?

回答

2

我假设你在根目录下使用.htaccess,使用下面的规则。

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/computers/notebooks-laptops/(.*) 
RewriteRule^/computers/laptops/%1 [R=301,L]