共享个人觉得比较完美的SEO URL修改方式

用于收藏精华贴子、网友共享的资料等。可以回复,不能发新贴。

版主: daimadaquan

版面规则
本版面不能发新贴,可以回复

共享个人觉得比较完美的SEO URL修改方式

帖子ytoem » 2011-04-17 22:01

优点是:没有缓存文件,不会写入数据库
缺点是:如果要自定义URL 的话,自己要写一个url_data.php文件定义

把附件改成.PHP
具体的例子:http://XXX.com/index.php?main_page=product_info&products_id=15

变为
http://XXX.com/products/15.html
还可以
http://XXX.com/products15.html
http://XXX.com/p15.html
http://XXX.com/p15/
http://XXX.com/products/mizumushinokusuri.html(必须定义url_data.php文件)
附件
html_output.php.txt
(17.19 KiB) 被下载 124 次
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

url_data.php

帖子ytoem » 2011-04-18 4:20

url_data.php 写法 如果不需要定义 请跳过这一步(需要放在根目录下)

<?php
$urlrpl = array(
"cid1" => "Hardware", <- cid分类ID
"cid1_4" => "Graphics_Cards",
"cid1_8" => "Keyboards",
"cid1_9" => "Mice",
"pid1" => "Matrox_G200_MMS", >- pid商品ID
"pid25" => "Microsoft_Internet_Keyboard_PS2",
"pid26" => "Microsoft_IntelliMouse_Explorer"
);
?>
最后由 ytoem 编辑于 2011-04-18 4:22,总共编辑了 1 次
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

.htaccess 的写法

帖子ytoem » 2011-04-18 4:22

.htaccess 的写法

RewriteEngine on
RewriteBase /
RewriteRule ^categories/Hardware.html /index.php?main_page=index&cPath=1 [L]
RewriteRule ^categories/Graphics_Cards.html /index.php?main_page=index&cPath=1_4 [L]
RewriteRule ^categories/Keyboards.html /index.php?main_page=index&cPath=1_8 [L]
RewriteRule ^categories/Mice.html /index.php?main_page=index&cPath=1_9 [L]
RewriteRule ^products/Matrox_G200_MMS.html /index.php?main_page=product_info&products_id=1 [L]
RewriteRule ^products/Microsoft_Internet_Keyboard_PS2.html /index.php?main_page=product_info&products_id=25 [L]
RewriteRule ^products/Microsoft_IntelliMouse_Explorer.html /index.php?main_page=product_info&products_id=26 [L]
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

Re: 共享个人觉得比较完美的SEO URL修改方式

帖子ytoem » 2011-04-18 4:35

请注意,附件的html_output.php是1.3.0.2的。
1。38.和1.39 相应稍微修改。不能直接上传,请注意 如果有人修改好的话传个论坛上去就是了

通过以上我们能达到URL,改写的目的。如果商品比较少的话,可以直接定义url_data.php的方式改写

默认形式如下
http://XXX.com/categories/12.html 分类
http://XXX.com/categories/12_11.html 二级分类
http://XXX.com/products/15.html 商品

商品多的话,只能这样了(当然如果你有时间定义url_data.php和.htaccess 的除外)

个人认为改写分类就行了。商品多的话
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

Re: 共享个人觉得比较完美的SEO URL修改方式

帖子ytoem » 2011-04-18 5:14

最后添加 /includes/configure.php

define('USE_PCONNECT', 'false'); // use persistent connections?
define('STORE_SESSIONS', 'db'); // leave empty '' for default handler or set to 'db'
define('USER_FRIENDLY_URLS_REWRITE', 'true');

添加最后一行开关
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

发一个避免收录动态页面

帖子ytoem » 2011-04-18 15:57

请存为robot.txt

User-agent: *
Sitemap: http://×××.com/store/sitemap.xml
Allow: /categories/
Allow: /products/
Disallow: /index.php?main_page=index&cPath*
Disallow: /index.php?main_page=product_info&products_id*
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

Re: 共享个人觉得比较完美的SEO URL修改方式

帖子ytoem » 2011-04-19 2:12

RewriteEngine On
RewriteBase /

RewriteRule ^categories/Hardware.html index.php?main_page=index&cPath=1 [L]
RewriteRule ^categories/Graphics_Cards.html index.php?main_page=index&cPath=1_4 [L]
RewriteRule ^categories/Keyboards.html index.php?main_page=index&cPath=1_8 [L]
RewriteRule ^categories/Mice.html index.php?main_page=index&cPath=1_9 [L]
RewriteRule ^products/Matrox_G200_MMS.html index.php?main_page=product_info&products_id=1 [L]
RewriteRule ^products/Microsoft_Internet_Keyboard_PS2.html index.php?main_page=product_info&products_id=25 [L]
RewriteRule ^products/Microsoft_IntelliMouse_Explorer.html index.php?main_page=product_info&products_id=26 [L]


RewriteRule ^products/(.*)notify_remove\.html index.php?main_page=product_info&products_id=$1&action=notify_remove [L]
RewriteRule ^products/(.*)notify\.html index.php?main_page=product_info&products_id=$1&action=notify [L]
RewriteRule ^products/(.*)add\.html index.php?main_page=product_info&products_id=$1&action=add_product [L]
RewriteRule ^products/(.*)\.html index.php?main_page=product_info&products_id=$1 [L]
RewriteRule ^categories/(.*)/filter(.*)/page(.*)/sort(.*)\.html index.php?main_page=index&cPath=$1&filter_id=$2&page=$3&sort=$4 [L]
RewriteRule ^categories/(.*)/sort(.*)/filter(.*)/page(.*)\.html index.php?main_page=index&cPath=$1&sort=$2&filter_id=$3&page=$4 [L]
RewriteRule ^categories/(.*)/filter(.*)/sort(.*)/page(.*)\.html index.php?main_page=index&cPath=$1&filter_id=$2&sort=$3&page=$4 [L]
RewriteRule ^categories/(.*)/sort(.*)/filter(.*)\.html index.php?main_page=index&cPath=$1&sort=$2&filter_id=$3 [L]
RewriteRule ^categories/(.*)/sort(.*)/page(.*)\.html index.php?main_page=index&cPath=$1&sort=$2&page=$3 [L]
RewriteRule ^categories/(.*)/page(.*)/sort(.*)\.html index.php?main_page=index&cPath=$1&page=$2&sort=$3 [L]
RewriteRule ^categories/(.*)\.html index.php?main_page=index&cPath=$1 [L]
RewriteRule ^order/(.*)\.html index.php?main_page&action=buy_now&products_id=$1 [L]
RewriteRule ^(.*)/display(.*)/page(.*)\.html index.php?main_page=$1&disp_order=$2&page=$3 [L]
RewriteRule ^shippinginfo\.html index.php?main_page=shippinginfo [L]
RewriteRule ^privacy\.html index.php?main_page=privacy [L]
RewriteRule ^conditions\.html index.php?main_page=conditions [L]
RewriteRule ^contact_us\.html index.php?main_page=contact_us [L]
RewriteRule ^gv_faq\.html index.php?main_page=gv_faq [L]
RewriteRule ^discount_coupon\.html index.php?main_page=discount_coupon [L]
RewriteRule ^specials\.html index.php?main_page=specials [L]
RewriteRule ^featured_products\.html index.php?main_page=featured_products [L]
RewriteRule ^products_new\.html index.php?main_page=products_new [L]
RewriteRule ^products_all\.html index.php?main_page=products_all [L]
RewriteRule ^tell_a_friend/to_(.*)/products(.*)\.html index.php?main_page=tell_a_friend&to_email_address=$1&products_id=$2 [L]
RewriteRule ^tell_a_friend/send/products(.*)\.html index.php?main_page=tell_a_friend&action=process&products_id=$1 [L]
RewriteRule ^tell_a_friend/products(.*)\.html index.php?main_page=tell_a_friend&products_id=$1 [L]
RewriteRule ^manufacturers_id(.*)\.html index.php?main_page=index&manufacturers_id=$1 [L]
RewriteRule ^redirect/manufacturers_id(.*)\.html index.php?main_page=redirect&action=manufacturer&manufacturers_id=$1 [L]
RewriteRule ^redirect_banner(.*)\.html index.php?main_page=redirect&action=banner&goto=$1 [L]
RewriteRule ^redirect_url-(.*) index.php?main_page=redirect&action=url&goto=$1 [L]
RewriteRule ^login\.html index.php?main_page=login [L]
RewriteRule ^logoff\.html index.php?main_page=logoff [L]
RewriteRule ^account\.html index.php?main_page=account [L]
RewriteRule ^shopping_cart\.html index.php?main_page=shopping_cart [L]
RewriteRule ^checkout_shipping\.html index.php?main_page=checkout_shipping [L]
RewriteRule ^advanced_search\.html index.php?main_page=advanced_search [L]
RewriteRule ^popup_shipping_estimator\.html index.php?main_page=popup_shipping_estimator [L]
RewriteRule ^news/(.*)\.html index.php?main_page=news_manager&pages_id=$1 [L]
RewriteRule ^news_manager_all_news\.html index.php?main_page=news_manager_all_news [L]
RewriteRule ^unsubscribe\.html index.php?main_page=unsubscribe [L]
RewriteRule ^reviews\.html index.php?main_page=reviews [L]
RewriteRule ^index\.html$ index.php?main_page=index [L]
ytoem
普通会员
普通会员
 
帖子: 20
注册: 2010-05-06 21:40

Re: 共享个人觉得比较完美的SEO URL修改方式

帖子Jack » 2011-04-20 21:30

不错,顶一个 :P
头像
Jack
论坛版主
论坛版主
 
帖子: 11665
注册: 2004-12-16 10:04

Re: 共享个人觉得比较完美的SEO URL修改方式

帖子xiao_min » 2011-04-21 10:32

感觉好复杂哦,其实不会影响网址不会影响seo就可以了吧
头像
xiao_min
VIP会员
VIP会员
 
帖子: 339
注册: 2010-06-08 11:17

Re: 共享个人觉得比较完美的SEO URL修改方式

帖子yahui870718 » 2011-04-27 20:55

搜藏了,以后会用到的
yahui870718
普通会员
普通会员
 
帖子: 48
注册: 2011-03-15 22:16
QQ 帐号: 493908654

下一页

回到 精华共享

在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客