Web Hosting Talk







View Full Version : .htaccess mod_rewrite assistance


jdk
01-29-2007, 04:31 PM
I am trying to take the following link:

http://www.sourarcade.com/play.php?gametitle=Amoebas&gameid=474

and turn it into the following:

http://www.sourarcade.com/play/Amoebas-474.html

I have the following in my .htaccess file

#start .htaccess code
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^gametitle\=([^&]+)\&gameid\=([^&]+)$
RewriteRule ^$ /play/%1-%2.html [R=301,L]

The following in my index.php to export the link:

echo "<a href='play/$getgames[gametitle]-$getgames[gameid].html'>$gametitle</a><br>";


For some reason it does not work correctly. I get a page not found when I try to access http://www.sourarcade.com/play/Amoebas-474.html


Any help would be appreciated. If you need FTP access, it can be provided. I am willing to compensate someone who can get this working properly.

Thanks

layer0
01-29-2007, 06:11 PM
Where does the problem actually lie? If it's the .htaccess file, then you can just try:

make a folder called "play" and insert this into its .htaccess. remove your current .htaccess in the parent directory.


Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)-(.*)\.html$ /play.php?gametitle=$1&gameid=$2

jdk
01-29-2007, 06:31 PM
It appears what is happening is my links think /play/ is a directory.

For example is you go to sourarcade.com and click on one of the links in the middle column the stylesheet doesnt work.

If you click on the normal links on the left column everything works fine.

I edited my play.php file to make the links all ../images/ instead of images/

For some reason I have to move back a directory eventhough I do not have a /play directory. Strange but it seems to work.

vx|brian
01-29-2007, 06:45 PM
jdk: You don't have a /play directory but the Internet browser has no clue of that, so it looks for /play/images and that's why it 404s. :)