1

I am getting a Internal 500 Error at present with my code below

What I have is a games site that calls it’s games (around 100) with one single php file:

game-play.php?content=GAME1
game-play.php?content=GAME2
game-play.php?content=GAME3

What I am trying to do is permanently redirect each game to its equivalent static .html page with the same name as the argument supplied in the above links in a new folder.

So the above would redirect to:

/games/GAME1.html
/games/GAME2.html
/games/GAME3.html

The code I currently have below is giving me internal 500 eror:

RewriteCond %{QUERY_STRING} content=([^/]+)/?  [NC]
RewriteRule ^/?  /games/?content.html [L,NC]

It seems like such a simple thing but I have tried countless variations with either internal error or page 404 or nothing at all.

2
  • There is no content.html in your URLs but your rule is using it. Commented Jun 2, 2014 at 16:19
  • I thought that ?content was holding the information for the page hence ?content.html would redirect to the page in the content variable if that makes sense. Commented Jun 2, 2014 at 16:54

2 Answers 2

1

You can use:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+game-play\.php\?content=([^\s&]+) [NC]
RewriteRule ^ /games/%1.html? [R=301,L]

RewriteRule ^games/([^./]+)\.html$ /game-play.php?content=$1 [L,QSA,NC]
Sign up to request clarification or add additional context in comments.

1 Comment

anubhava, This looks promising. thank you. only problem I have is the game still loads as normal even though I have not created the new games in the games folder it points too. so the browser url reads www.domainname.com/games/gamesname which is what I was looking for but even though that page does not exist yet the game still loads. hope that makes sense. would adding .html after the %1 on line 2 give me www.domainname.com/games/gamesname.html ? if so that might be exactly right because that currently gives me a 404 error which is what I was expecting.
0

To redirect
http://www.domain.com/game-play.php?content=GAME1
to
http://www.domain.com/game/GAME1.html

Try:

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /game-play.php?content=$1 [L]

1 Comment

Hey David, Thanks but no joy there. It has no effect at all the link goes exactly where it would normally go.

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.