通过 htaccess 重写一个 URL
Rewrite a URL via htaccess
我有一个 URL 结构如下
http://www.naturaflowers.com/100-fresh-cut-wholesale-flowers.html
我想重写URL喜欢
http://www.naturaflowers.com/fresh-cut-wholesale-flowers.html
我们使用 "ultimate SEO url Plugin" 生成 SEO 友好 URL。旧的 URL 结构是 /index.php?main_page=index&cPath=category_id 。我的 htaccess 代码如下:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-(.*).html$ index\.php?main_page=index&cPath=&%{QUERY_STRING} [L]
The above mentioned plugin and this htaccess code rewrite
index.php?main_page=index&cPath=100 to
/100-fresh-cut-wholesale-flowers.html . And now I want to
/100-fresh-cut-wholesale-flowers.html rewrite to
/fresh-cut-wholesale-flowers.html everywhere in my website through
htaccess .
RewriteRule ^(/?)\d+-(.*)$
你的规则是这样的:
RewriteEngine On
RewriteBase /
RewriteRule ^[0-9]+-(.+?\.html)$ / [L,R=302,NC]
RewriteRule ^(.+?)\.html$ index\.php?main_page=index&cPath= [L,QSA,NC]
我有一个 URL 结构如下
http://www.naturaflowers.com/100-fresh-cut-wholesale-flowers.html
我想重写URL喜欢
http://www.naturaflowers.com/fresh-cut-wholesale-flowers.html
我们使用 "ultimate SEO url Plugin" 生成 SEO 友好 URL。旧的 URL 结构是 /index.php?main_page=index&cPath=category_id 。我的 htaccess 代码如下:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-(.*).html$ index\.php?main_page=index&cPath=&%{QUERY_STRING} [L]
The above mentioned plugin and this htaccess code rewrite index.php?main_page=index&cPath=100 to /100-fresh-cut-wholesale-flowers.html . And now I want to /100-fresh-cut-wholesale-flowers.html rewrite to /fresh-cut-wholesale-flowers.html everywhere in my website through htaccess .
RewriteRule ^(/?)\d+-(.*)$
你的规则是这样的:
RewriteEngine On
RewriteBase /
RewriteRule ^[0-9]+-(.+?\.html)$ / [L,R=302,NC]
RewriteRule ^(.+?)\.html$ index\.php?main_page=index&cPath= [L,QSA,NC]