close
最近為了要讓網站能更親近 搜尋引擎 ,剛好又是租用的主機聽說有支援...

網路上很多SEO都寫說,搜尋引擎的機器人遇到,程式會自動跳過..

就不把網站內容收入...好像就是遇到 ? 帶值的頁面都不會在進入抓取..

那要如何讓網站內容收入進去呢??就是靜態的網址,讓搜尋引擎認為是一般的html

http://www.ofsun.com/index.html

真實的網頁其實是

http://www.ofsun.com/index.php

那就要靠 Apache 的 mod_rewrite 模組


將靜態網頁對應到動態網頁@@

至於 Apache 要如何開啟 mod_rewrite 這部份就自己看吧..我也沒試過..

因為是租用主機所以是請主機公司的工程師幫忙開啟..

所以 要開啟 mod_rewrite 這一段,就請自己試看看
----------------------------------------------------------
修改 Apache 中的 http.conf
然後搜尋並將以下兩行前的注解「#」拿掉

#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c

再搜尋 http.conf 中

AllowOverride None

的語句,將其改為

AllowOverride All

在重新啟動 Apache
-------------------------------------------------

接下來就是在 用記事本 編寫 .htaccess

如果沒有就自己新增記事本,再將檔名 改成 .htaccess 但在windows下面可能沒辦法改成這種名稱

因為沒有檔名 所以可以先設成 a.htaccess 在上傳到ftp在ftp上面就可以改名 .htaccess 再下載下來

用記事本開啟


RewriteEngine on
RewriteBase /

以上這兩行是一定要寫的

----------------------------------------------------

RewriteRule ^index.html$ index.php
^ 起
$尾

這一段就是說 index.html 對應到 index.php

RewriteRule ^shop_([a-z0-9\-]+).html$ shop.php?bno=$1

( )中就是找尋網址內這一段的小寫字母和數字 將他對應成 $1

如果有兩個變數那就是 $2 以下類推囉...

RewriteRule ^shop_([a-z0-9\-]+)_([a-z0-9\-]+).html$ shop.php?bno=$1$&sno=$2

http://www.ofsun.com/shop_1.html  就對應到  http://www.ofsun.com/shop.php?bno=1

這大概就是基本的語法...

再詳細的設定請自己到以下網址參考
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

arrow
arrow
    全站熱搜

    abpop23 發表在 痞客邦 留言(0) 人氣()