首页 文章

通过htaccess重写URL

提问于
浏览
0

我在以下结构中有一个URL

http://www.naturaflowers.com/100-fresh-cut-wholesale-flowers.html

我想重写URL

http://www.naturaflowers.com/fresh-cut-wholesale-flowers.html

我们使用“终极SEO url插件”来生成SEO友好的URL . 旧的URL结构是/index.php?main_page=index&cPath=category_id . 我的htaccess代码如下:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-(.*).html$ index\.php?main_page=index&cPath=$1&%{QUERY_STRING} [L]

上面提到的插件和这个htaccess代码重写index.php?main_page = index&cPath = 100到/100-fresh-cut-wholesale-flowers.html . 现在我想通过htaccess将/100-fresh-cut-wholesale-flowers.html重写到我网站的所有地方/fresh-cut-wholesale-flowers.html .

2 回答

  • 0

    你有这样的规则:

    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^[0-9]+-(.+?\.html)$ /$1 [L,R=302,NC]
    
    RewriteRule ^(.+?)\.html$ index\.php?main_page=index&cPath=$1 [L,QSA,NC]
    
  • 0
    RewriteRule ^(/?)\d+-(.*)$ $1$2
    

相关问题