apache 301重定向

apache 301跳转对seo是友好的,所以用apache的配置文件进行301跳转时很有用的。

修改 apache配置文件

例如,我现在服务器上的网站域名是 www.mytwo.com ,我又想让www.myone.com也打开www.mytwo.com,代码如下

<VirtualHost *:80>
ServerName www.myone.com
RedirectMatch Permanent ^/(.*) http://www.mytwo.com/$1
</VirtualHost>

另一个示例,apache虚拟主机配置示例:

<VirtualHost 213.5.65.230:80>
    ServerAdmin cc@cc.com
    ServerName www.hellokey.com
    ServerAlias hellokey.com
    RedirectMatch Permanent ^/(.*) http://www.hellokeykey.com/$1
</VirtualHost>

将www.hellokey.com 301 跳转到 www.hellokeykey.com

如果使用.htaccess 来实现,直接到网址:http://www.htaccesseditor.com/sc.shtml 来设置就好了,这个是在线的傻瓜编辑器,将生成的.htaccess贴到我们的.htaccess文件就好了。

转载标明出处:hellokeykey.com 右兜钥匙

apache .htaccess no-www to www

参考:http://www.askitexpert.com/question/redirect-nonwww-to-www-in-apache/10

有两种办法

1.在.htaccess的适当位置加入如下代码 yourdomain改成你的域名

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteRule ^(.*) http://www.yourdomain.com/$1 [L,R=301]

2.在 apache的配置文件中

RewriteEngine On
RewriteOptions Inherit
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.yourdomain.com/$1 [L,R]

继续阅读“apache .htaccess no-www to www”

magento img 标签 使用

在magento的phtml文件中参考如下代码

<img src="<?php echo $this->getSkinUrl('images/myImage.png') ?>" alt="" />

在后台的CMS中使用 ,参考如下代码

<img src="{{skin url='images/media/myImage.jpg'}}" alt="" />

其中(‘images/myImage.png’)中的images是主题文件夹中的images文件夹

转载标明出处:hellokeykey.com 右兜钥匙

linux 安装 magento 文件权限

进入magento根目录

执行如下设置权限的命令,magento即可以正常安装

# chmod o+w var var/.htaccess app/etc

# chmod -R o+w media

若在使用magento connect的时候提示权限报警,进入magento根目录执行如下命令

#find . -type d -exec chmod 777 {} \;

转载标明出处:hellokeykey.com 右兜钥匙

magento 添加省 市 地址

最新插件地址,见文章:http://www.hellokeykey.com/?p=2797

范例如下 在mysql中 执行下列sql语句

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, ‘CN’, ‘BJ’, ‘北京’);

红色部分,应该是你的maento数据库名字,本例中使用 “magento” 绿色部分,应该是你magento数据库中的表的名字,注意你的表有没有添加前缀,本例中使用“directory_country_region”

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'BJ', '北京');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'GD', '广东');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'SH', '上海');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'TJ', '天津');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HE', '河北');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'SX', '山西');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'NM', '内蒙古');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'LN', '辽宁');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'JL', '吉林');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HL', '黑龙江');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'JS', '江苏');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'ZJ', '浙江');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'AH', '安徽');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'FJ', '福建');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'JX', '江西');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'SD', '山东');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HA', '河南');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HB', '湖北');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HN', '湖南');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'GX', '广西');
INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HI', '海南');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'CQ', '重庆');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'SC', '四川');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'GZ', '贵州');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'YN', '云南');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'XZ', '西藏');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'SN', '陕西');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'GS', '甘肃');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'QH', '青海');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'NX', '宁夏');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'XJ', '新疆');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'HK', '香港');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'AM', '澳门');

INSERT INTO `magento`.`directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'CN', 'TW', '台湾');
'TW', '台湾');

我写了个简单的插件,可以自动将上面的地址添加到magento:点此下载此插件

将里面的app覆盖你的magento根目录的app即可

也请参考此篇文章:http://www.webshopapps.com/blog/2011/04/adding-new-regionsstates-to-your-magento-installation-2/

继续阅读“magento 添加省 市 地址”

apache 多ip 多域名 虚拟主机配置

#由于是多 ip 监听同一个端口所以这样写
Listen 80
#若是多ip 多端口 则是
#Listen 192.170.2.1:80
#Listen 192.170.2.5:8000
#由于使用多ip NameVirtualHost这样设置了下,没查到详细的资料
NameVirtualHost 1.2.3.4:80
NameVirtualHost 5.6.7.8:80

#第一个ip给域名www.hellokeykey.com

<VirtualHost 1.2.3.4:80>
ServerAdmin key@hellokeykey.com
DocumentRoot /var/www/html/hellokeykey.com
ServerName www.hellokeykey.com
ServerAlias hellokeykey.com
</VirtualHost>

#第二个ip给域名www.magentokey.com

<VirtualHost 5.6.7.8:80>
ServerAdmin key@hellokeykey.com
DocumentRoot /var/www/html/magentokey.com
ServerName www.magentokey.com
ServerAlias magentokey.com
</VirtualHost>

转载标明出处:hellokeykey.com 右兜钥匙

magento 安装系统环境需求

magento安装系统需求以及检测

请参考官方的系统需求:http://www.magentocommerce.com/system-requirements

  • Supported Operating Systems:
    • Linux x86, x86-64
  • Supported Web Servers:
    • Apache 1.3.x
    • Apache 2.0.x
    • Apache 2.2.x
  • Supported Browsers:
    • Microsoft Internet Explorer 6 and above
    • Mozilla Firefox 2.0 and above
    • Apple Safari 2.x
    • Google Chrome
    • Adobe Flash browser plug-in should be installed
  • PHP Compatibility:
    • 5.2
    • Required extensions:
      • PDO_MySQL
      • simplexml
      • mcrypt
      • hash
      • GD
      • DOM
      • iconv
      • curl
      • SOAP (if Webservices API is to be used)
    • Safe_mode off
    • Memory_limit no less than 256Mb (preferably 512)
  • MySQL:
    • 4.1.20 or newer
    • InnoDB storage engine
  • SSL:
    • If HTTPS is used to work in the admin, SSL certificate should be valid. Self-signed SSL certificates are not supported
  • Server – hosting – setup:
    • Ability to run scheduled jobs (crontab) with PHP 5
    • Ability to override options in .htaccess files

我将官方的magento检测文件放在这里,大家可以用这个php检测文件检测你的主机是否达到了magento的要求 点击下载:magento-check.zip 其中SSL不是必须的,你要是会用的话,才有必要去装。apache php mysql的版本和需要的模板要达到如上的要求。记得你的apache要开启.htaccess的支持,我有很多次忘记这个而无法安装magento。 转载表明出处:hellokeykey.com