2012-09-05 19 views
0

我已經搜索了很多並在我的.htaccess文件中實現了許多正則表達式,但無法成功。如何找到一個通用的方式,使我的網址搜索引擎友好?需要一種通用的方式來創建SEO友好的URL

目前,這是在我的.htaccess文件:

RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?page=$1 [L,QSA] 

我需要做的就是要改變這樣的網址:

http://localhost/abc/index.php?page=boats_for_sale 

這樣:

http://localhost/abc/boats_for_sale 

同樣,我想隱藏我的URL中的所有查詢字符串。

我該怎麼做到這一點?

+0

做它必須是.htaccess或者你可以與其他sol達成你想要的 – metadice

回答

1

喜歡的東西,它的工作:

URL重寫模塊激活

# Avoids problems with mod_rewrite 
    Options +FollowSymlinks 
# Activate rewriting module 
    RewriteEngine on 
# Set base URL directory rewrites 
    RewriteBase/

重寫URL參數

RewriteRule ^abc/([a-zA-Z0-9_-]+)$ abc/index.php?page=$1 

PLZ讀重寫MOD聖經: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html