2013-02-24 122 views
2

我想將以下網址重命名爲適合SEO的網址。使用.htaccess將內部頁面網址重命名爲seo友好的網址

Change the following URL : http://www.peacockgirls.com/index.php?page=1 into http://www.peacockgirls.com 
Change the following URL : http://www.peacockgirls.com/index.php?page=2 into http://www.peacockgirls.com/greece-escort 
Change the following URL : http://www.peacockgirls.com/index.php?page=3 into http://www.peacockgirls.com/athens-escort 
Change the following URL : http://www.peacockgirls.com/index.php?page=4 into http://www.peacockgirls.com/bookings 
Change the following URL : http://www.peacockgirls.com/index.php?page=5 into http://www.peacockgirls.com/jobs 
Change the following URL : http://www.peacockgirls.com/index.php?page=6 into http://www.peacockgirls.com/contact-us 
Change the following URL : http://www.peacockgirls.com/index.php?page=24 into http://www.peacockgirls.com/articles 
Change the following URL : http://www.peacockgirls.com/index.php?page=7 into http://www.peacockgirls.com/links 
Change the following URL : http://www.peacockgirls.com/index.php?profile=22 into http://www.peacockgirls.com/profile/aleena 
Change the following URL : http://www.peacockgirls.com/index.php?profile=40 into http://www.peacockgirls.com/profile/fabiana 
Change the following URL : http://www.peacockgirls.com/index.php?profile=48 into http://www.peacockgirls.com/profile/sabrina 
Change the following URL : http://www.peacockgirls.com/index.php?profile=69 into http://www.peacockgirls.com/profile/suzanna 
Change the following URL : http://www.peacockgirls.com/index.php?profile=63 into http://www.peacockgirls.com/profile/anna 
Change the following URL : http://www.peacockgirls.com/index.php?profile=70 into http://www.peacockgirls.com/profile/sam 
Change the following URL : http://www.peacockgirls.com/index.php?profile=61 into http://www.peacockgirls.com/profile/Larissa&Samantha 
Change the following URL : http://www.peacockgirls.com/index.php?profile=54 into http://www.peacockgirls.com/profile/McKenzie 
Change the following URL : http://www.peacockgirls.com/index.php?profile=29 into http://www.peacockgirls.com/profile/valery 

如果你告訴我4個或5個網址使用.htaccess重命名技術,我該怎麼辦的其他網址。我被賦予了這項任務,但不能這樣做。

+0

嘛,你嘗試過這麼遠嗎?你沒有發佈你的當前設置,所以我們不可能指出這個問題。我希望你不要指望某人在這裏爲你做功課......尤其是因爲這是重寫MOD的一個基本用法,你需要的一切都有很好的文檔記錄和解釋,包括很好的基本例子。 – arkascha 2013-02-24 09:54:03

回答

1

有了這樣的任務,我會去RewriteMap

您可以使用兩個單獨的地圖文本文件(用於更好的文件管理):一個用於配置文件,一個用於頁面(用於其他類型重寫的任何新文件)。

.htaccess可以設置這樣:

RewriteMap userid txt:/etc/apache2/useridmap.txt 
RewriteRule ^/index.php?page=(.+) /profile/${userid:$1} [L,R=301] 

地圖文本文件格式如下:

# Comment line 
MatchingKey SubstValue 
MatchingKey SubstValue # comment 

在你的情況下,配置文件的文本文件可能如下所示:

22 aleena 
40 fabiana 
# more mappings 

對於頁面重定向你可以用下面的方法(圖文件也會有所不同,以及RewriteRule表達式)

任何工作之前,我會建議通過RewriteMapdocumentation第一去,所以你懂的工具,即它的配置和使用。

我希望這將是您的任務的好方向。

1
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule %{REQUEST_FILENAME} !-f 
    RewriteRule %{REQUEST_FILENAME} !-d 
    RewriteBase/

    RewriteRule ^/greece-escort/?$ /index.php?page=2 [NC,L] 
    RewriteRule ^/athens-escort/?$ /index.php?page=3 [NC,L] 
    RewriteRule ^/bookings/?$ /index.php?page=4 [NC,L] 
    RewriteRule ^/jobs/?$ /index.php?page=5 [NC,L] 
    RewriteRule ^/contact-us/?$ /index.php?page=6 [NC,L] 
    RewriteRule ^/articles/?$ /index.php?page=24 [NC,L] 
    RewriteRule ^/links/?$ /index.php?page=7 [NC,L] 
    RewriteRule ^/profile/aleena/?$ /index.php?profile=22 [NC,L] 
    RewriteRule ^/profile/fabiana/?$ /index.php?profile=40 [NC,L] 
    RewriteRule ^/profile/sabrina/?$ /index.php?profile=48 [NC,L] 
    RewriteRule ^/profile/suzanna/?$ /index.php?profile=69 [NC,L] 
    RewriteRule ^/profile/anna/?$ /index.php?profile=63 [NC,L] 
    RewriteRule ^/profile/sam/?$ /index.php?profile=70 [NC,L] 
    RewriteRule ^/profile/Larissa&Samantha/?$ /index.php?profile=61 [NC,L] 
    RewriteRule ^/profile/McKenzie/?$ /index.php?profile=54 [NC,L] 
    RewriteRule ^/profile/valery/?$ /index.php?profile=29 [NC,L] 
</IfModule> 

的.htaccess