February 13th, 2012, 09:30 AM
404 Not Found for RewriteRule
I want to get some basic RewriteRules setup for a htaccess file. They are going to be redirected to one single page, and the content generated depending on the get parameters.
Eg localhost.test/index.php?page=test becomes localhost.test/test/ and localhost.test/index?page=another becomes localhost.test/another.
My PHP script works when I use the long URL's but I get 404 Not Found when I type in the short URLs.
My htaccess file, created in notepad and encoded in ANSI:
Apache access log:
Options +FollowSymlinks -MultiViews
RewriteRule ^test$ index.php?page=test [NC]
127.0.0.1 - - [13/Feb/2012:15:22:44 +0000] "GET /test/ HTTP/1.1" 404 203
127.0.0.1 - - [13/Feb/2012:15:22:44 +0000] "GET /favicon.ico HTTP/1.1" 404 209
Apache error log:
Would appreciate any help for this.
[Mon Feb 13 15:22:44 2012] [error] [client 127.0.0.1] File does not exist: E:/Documents/test_web/test
[Mon Feb 13 15:22:44 2012] [error] [client 127.0.0.1] File does not exist: E:/Documents/test_web/favicon.ico
March 11th, 2012, 10:45 AM
Does requesting index.php?page=test show you what you want? That's the first step.
Did you request /test or /test/ ? Your regular expression doesn't match /test/, so that would result in a 404, whereas /test should match.
Explain your problem instead of asking how to do what you decided was the solution.