2

我想将以下 URL 重命名为 SEO 友好 URL。

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 个 URL 重命名技术.htaccess,我将使用剩余的 URL。我被赋予了这个任务,但我做不到。

4

2 回答 2

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重定向,您可以使用以下方法(地图文件和表达式会有所不同 )

在进行任何工作之前,我建议您先阅读RewriteMap 文档,以便您了解该工具,即它的配置和用法。

我希望这将是您任务的良好方向。

于 2013-02-24T17:14:00.933 回答
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

于 2015-03-06T15:09:41.080 回答