mod_rewrite seo 友好 url
mod_rewrite seo friendly url
我让 youtube 可以播放视频,并且我正在让自己成为一个网站,但是我被困在做一些 SEO 友好 urls 和 mod_rewrite 以下是我的代码使用
RewriteRule /lets-play/(.*)/games.php /lets-play.php?platform=
以上方法不起作用,访问lets-play/PS4/games的预期页面时得到404。php
也试过
RewriteRule /lets-play-(.*)-games.php /lets-play.php?platform= (this is the ideal solution)
RewriteRule /lets-play/(.*)\games.php /lets-play.php?platform= (results in 500 error)
我现在有一个页面,您可以在其中从可用列表(ps4、xbox one、pc 等)中选择一个平台,一旦您选择一个平台,您将被带到 url 有 ?platform=PS4 (或者你选择的任何东西)但是我想要的是 lets-play-ps4-games if possible if not lets-play/ps4/games will do
我的代码是否有明显的错误我遗漏了?我假设重写只是掩盖了 url 以使其看起来像其他东西也打开了重写引擎。
无法在本地主机上提供 link。
谢谢,
詹姆斯.
编辑
我应该补充一点,我是 htaccess 的新手。
删除 RewriteRule
中的第一个斜杠
RewriteRule lets-play-(.*)-games.php lets-play.php?platform= [L,QSA] # your ideal solution
RewriteRule lets-play/(.*)/games.php lets-play.php?platform= [L,QSA]
同时添加 [L]
以在找到匹配项后停止查找匹配项
和 QSA
以正确附加查询字符串..
这意味着
lets-play/PS4/games.php?date=today
将正确重写为
lets-play.php?platform=PS4&date=today
我让 youtube 可以播放视频,并且我正在让自己成为一个网站,但是我被困在做一些 SEO 友好 urls 和 mod_rewrite 以下是我的代码使用
RewriteRule /lets-play/(.*)/games.php /lets-play.php?platform=
以上方法不起作用,访问lets-play/PS4/games的预期页面时得到404。php 也试过
RewriteRule /lets-play-(.*)-games.php /lets-play.php?platform= (this is the ideal solution)
RewriteRule /lets-play/(.*)\games.php /lets-play.php?platform= (results in 500 error)
我现在有一个页面,您可以在其中从可用列表(ps4、xbox one、pc 等)中选择一个平台,一旦您选择一个平台,您将被带到 url 有 ?platform=PS4 (或者你选择的任何东西)但是我想要的是 lets-play-ps4-games if possible if not lets-play/ps4/games will do
我的代码是否有明显的错误我遗漏了?我假设重写只是掩盖了 url 以使其看起来像其他东西也打开了重写引擎。
无法在本地主机上提供 link。
谢谢,
詹姆斯.
编辑
我应该补充一点,我是 htaccess 的新手。
删除 RewriteRule
RewriteRule lets-play-(.*)-games.php lets-play.php?platform= [L,QSA] # your ideal solution
RewriteRule lets-play/(.*)/games.php lets-play.php?platform= [L,QSA]
同时添加 [L]
以在找到匹配项后停止查找匹配项
和 QSA
以正确附加查询字符串..
这意味着
lets-play/PS4/games.php?date=today
将正确重写为
lets-play.php?platform=PS4&date=today