开发者

Mod_Rewrite with multiple PHP variables and dynamic text

So here's the deal:

episode.php?s=1&e=3 brings up information for season 1 episode 3.

So make it SEO fri开发者_如何转开发endly I want to be able to have users be able go to the following:

domain.com/episodes/ShowName_Season_1_Episode_3_The_Title_Of_The_Episode.html (or without the .html, doesn't really matter).

This is what I have so far:

RewriteRule ^episodes/([a-z0-9-]+)_$_([a-z0-9-]+)_$_([a-z0-9-]+).html episode.php?s=$1&e=$2

I know this is not right...how can I make it take the two numbers in the rewritten URL and associate them with PHP GET variables in the actual URL?

I know how to do more basic mod_rewrites but this one has been confusing me. I am guessing it is something stupid, so thanks in advance for your patience.


Here's what you can do:

RewriteEngine ON

#domain.com/episodes/ShowName_Season_1_Episode_3_The_Title_Of_The_Episode.html
RewriteRule ^episodes/([a-z0-9\-]+)_Season_([0-9]+)_Episode_([0-9]+)_(.*)$ episode.php?s=$2&e=$3 [NC,L]

#Even more SEO friendly: http://domain.com/ShowName/Season/3/episode/4/title/
RewriteRule ^episodes/([a-z0-9\-]+)/season/([0-9]+)/episode/([0-9]+)/(.*)/? episode.php?s=$2&e=$3 [NC,L]

#or Even more SEO friendly: http://domain.com/episodes/ShowName/season-3/episode-1/title
RewriteRule ^episodes/([a-z0-9\-]+)/season\-([0-9]+)/episode\-([0-9]+)/(.*)/? episode.php?s=$2&e=$3 [NC,L]

I don't recommend to use "_" for SEO but "-"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜