I keep getting a 404 error and I'm not sure why. Here's the code in my .htaccess:
<ifmodule mod_rewrite.c> RewriteEngine On RewriteRule lyrics/a/page/(.*)$ lyrics/a/\?current_page=$1[L] </ifmodule>
Thanks for the help!
jdMorgan
6:36 pm on Feb 15, 2010 (gmt 0)
Dump the <IfModule> container unless you require this code to fail silently when mod_rewrite is not available.
Start anchor the RewriteRule pattern, unless you want to match "lyrics/a/page/<anything>" preceded by any number of any characters, filepath-parts, or directory-paths.
Do not escape the question mark in the substitution URL.
Observe required mod_rewrite syntax precisely; You are missing a space ahead of [L].
I recommend a thorough read of the mod_rewrite docs at apache.org before use. Failing to do that can be close to suicide. More resources are cited in our Apache Forum Charter.
I do not get a server error however I still get the 404 error. The links can be lyrics/a/(numbers 1 - 99) which is what I need to point to the corresponding php code link.
Examples: lyrics/a/2 needs to point to lyrics/a/?current_page=2, lyrics/a/3 needs to point to lyrics/a/?current_page=3, lyrics/a/25 needs to point to lyrics/a/?current_page=25
[edited by: jshpik1 at 12:27 pm (utc) on Feb 17, 2010]
I do not get a server error however I still get the 404 error. The links can be lyrics/a/(numbers 1 - 99) which is what I need to point to the corresponding php code link.
It would be helpful to you (and likely to us) if you would report the error message in your server error log. The access log will show you the requested URL. The error log will show you the (probalby-incorrect) filepath that that URL is being rewritten to.
"/lyrics/a/" must be a path that resolves to a script which accepts the "current_page" query string. If this filepath association for "/lyrics/a/" is not defined using DirectoryIndex, then it won't resolve, and you'll get a 404. I assume that you'd want to point it to "/lyrics/a/index.php" or similar. If you wish to 'share' the script among (again, guessing here) /lyrics/a/ and /lyrics/b/ etc., then you'll likely want to define the DirectoryIndex as a script in your top-level directory or use another rewriterule to "map" all these "letter" subdirectory index requests to the script in your top-level directory.