Categories

SEO關鍵字

OpenCart 在設計時可以讓商店使用搜索引擎優化網址 (Search Engine Optimized URLs),此功能可以套用到產品目錄、產品、品牌及資訊面頁中。SEO關鍵字可以定義各種頁面並紀錄在資料庫表格 url_alias 中,查看每個頁面要求,並轉換成內部網址。

啟用SEO關鍵字功能

如想啟用SEO關鍵字功能,可前往系統中的 設定 (Setting) 頁面,在伺服器設定中可以找到啟用此功能的按鈕。

System Setting - SEO URL

伺服器設定文件

當下載整個 OpenCart 時,當中已包含了可以使伺服器銜接SEO關鍵字功能的編碼。從 Upload 資料夾中可以找到一個命名為 .htaccess.txt 的文件(如果沒有選擇查看文件副檔名稱的選項,請先開啟。),將 .txt 的副檔名刪去後,便可以啟用SEO關鍵字功能。但如果還未有效果,請向網頁寄存公司查詢能否支援此功能。

下列為 .htaccess 文件中的編碼:

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: https://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none

.htaccess 文件必須放置在商店的主要資料夾(Root Folder)內,否則整個功能是不能夠運作。假如從cPanel內找不到這個文件,可以先嘗試從設定中查看是否隱藏了部份格式的文件。但真的沒有這個檔案的存在,可以複製上方的編碼並命名文件為 .htaccess 亦可。

如果OpenCart存放的位置是 public_html/store 時,便要將以下的編碼改成:

RewriteBase /store

文件預設時,重寫引擎是啟用的,如果使用者並不是從 OpenCart 官方網站自行下載時,而功能並未成功啟用,可以查看以下的編碼是否被設成 Off

RewriteEngine On

每一個SEO關鍵字也是獨一無二的,不能重覆使用。所以定立SEO關鍵字時,都必須清晰代表每頁。而SEO關鍵字只可以使用"-"作為字與字之間的分隔,空白鍵或其他符號是不允許使用的。

nikon-camera
nikon camera

Admin Product - SEO Example

上述圖片以產品「Nikon D300」為例,將產品的SEO關鍵字設定為 nikon-d300,之後儲存變更。在第一及第二步的設定確認經已啟用後,再於網址中輸入下列字眼:

www.mystore.com/nikon-d300

Store front - SEO Example

總括而言,創建SEO關鍵字將有助整理商店頁面的網址並優化網站於搜索引擎的評分。