0

I'm attempting to generate dynamic 'pretty URLs' via .htaccess so that http://mysite.com/episode.php?episode=1 will become http://mysite.com/1, however obviously I want this to be applicable to all episode numbers between a potential range of 1 - 999. I have the following, however I'm getting a 503 error thrown when I load up my .htaccess file:

Options -Multiviews

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^mysite\.com$
RewriteRule ^(.*) http://mysite.com/$1 [R=301,L]

RewriteRule ^/episode/\(\?:0|\[1-9\]\\d{0,2}\)$ //episode.php?episode=(?:0|[1-9]\d{0,2}) [L]

I can't seem to work out where I'm going wrong and not really understanding why a 503 is being thrown.

Ryan
  • 767
  • 3
  • 9
  • 31

1 Answers1

0
RewriteRule ^episode/(0|[1-9]\d{0,2})$ /episode.php?episode=$1 [L,QSA]

More information about QSA: apache.org/docs/current/rewrite/flags.html#flag_qsa

Markus Jarderot
  • 86,735
  • 21
  • 136
  • 138
  • Thanks for your response. Have I got this the wrong way round? I want `http://mysite.com/episode.php?episode=1` to become `http://mysite.com/1` rather than the other way round. When I load as you've formatted above, and as I did previous, it looks like it's trying to change the other way round. Am I missing something? – Ryan May 22 '12 at 17:01
  • You are looking at it from the wrong direction. When a user navigates to `http://mysite.com/1`, the server will serve her `http://mysite.com/episode.php?episode=1` instead. The URL the user sees will still be `http://mysite.com/1`. – Markus Jarderot May 22 '12 at 17:26
  • Okay, now I understand. That still doesn't appear to be happening though. If a user navigates to `http://mysite.com/1` I'm getting a 404 error thrown. – Ryan May 22 '12 at 17:41
  • Yea, I thought of that already and I get the same 404 thrown. I'm completely baffled to be honest! – Ryan May 22 '12 at 17:46
  • It seems RewriteRule doesn't like the leading slash. I removed it. – Markus Jarderot May 22 '12 at 17:55