Hi guys, Get a 500 whenever I put this in the htaccess file. RewriteRule ([0-9]+)/(.*?)/(.*?)/index.php?lyric=$1 Code (markup): Im foreign when it comes to this. Any ideas? The complete htaccess is this Options +FollowSymLinks RewriteEngine On RewriteRule letters/(.*)/ /index.php?letter=$1 RewriteRule artists/(.*)/ /index.php?band=$1 RewriteRule ([0-9]+)/(.*?)/(.*?)/index.php?lyric=$1 Code (markup): Works whenever I take the last line out. Cheers.
RewriteRule ([0-9]+)/(.*?)/(.*?) /index.php?lyric=$1 I assume that's what you were aiming for - you need to separate the pattern and destination with a space, otherwise it doesn't make any sense.
I have noticed some servers don't like some regex, but have never found any info about this. Try taking parts of the pattern out until you find the issue. .*? is the same as .* by the way Try this: RewriteRule ([0-9]+)/(.+)?/(.+)? /index.php?lyric=$1 Code (markup):
Hey KRT. Seems to have worked, however, all the lyrics now have a str_ireplace call to undefined function. global $quarter_banner, $tower, $square; $query = "SELECT id, title, artist, lyrics, album FROM `lyrics` WHERE id = '" . $id . "'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<div id="' . $row['title'] . '" class="album"><h3 style="margin-left: 0; background-color: #f9f9f9; margin-bottom: 5px; color: #333333;">' . $row['title'] . ' by: ' . $row['artist'] . '</h3>'; $high = $_REQUEST['high']; $lyrics = str_ireplace($high, "<span style=\"background-color: #FFFF66\">$high</span>", $row['lyrics']); $arr = array("artist" => $row['artist'], "title" => $row['title'], "album" => $row['album'], "lyrics" => $lyrics, "id" => $row['id']); return $arr; } } Code (markup): I am very new to this. So can someone tell me if this is linked to the rewrite code at all?
str_ireplace is only available for PHP5. I take it you have moved the script to a new server that support PHP4, not PHP5? Here is a workaround for that issue: Change the line: $lyrics = str_ireplace($high, "<span style=\"background-color: #FFFF66\">$high</span>", $row['lyrics']); PHP: To: $lyrics = preg_replace('/' . preg_quote($high, '/') . '/i', '<span style="background-color: #FFFF66">$1</span>', $row['lyrics']); PHP: Come to think of it, the preg_replace() solution is better for this case as it preserves the letter casing.
Good observation. It isn't needed though, but it would be better with it. Options +FollowSymLinks RewriteEngine On RewriteRule ^letters/(.*)/ /index.php?letter=$1 RewriteRule ^artists/(.*)/ /index.php?band=$1 RewriteRule ^([0-9]+)/(.+)?/(.+)? /index.php?lyric=$1 Code (markup): The ^ means that the pattern that is being matched has to be at the start (right after the domain name).