4

So here's the deal:

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

So make it SEO friendly 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.

1 Answer 1

3

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 "-"

Sign up to request clarification or add additional context in comments.

3 Comments

For some reason when I use the last line that you said would be best for SEO, I lose all style info and my images no longer appear. It goes to the correct PHP page, but none of the styling is there. Pretty much all text. EDIT: it is now trying to find my images and css stuff ehre: episodes/dexter/season-3/episode-2/css/img/icons/diglog24.png instead of /cdd/img/icons/diglog24.png where it's supposed to be.
to show the images css, js, etc. you have to put the base tag in your html
tttony is right. Make sure in your HTML code you use the base tag or you reference all your CSS, JS or Images with / eg: <img src="/css/img/icons/diglog24.png"> that way you will see the image correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.