Simple mod_rewrite test
Posted by: AMessier (---.tampfl.fios.verizon.net)
Date: February 03, 2015 04:49AM

1. Windows 7 x64
2. Wamp 2.5 x64
3. Apache 2.4.9 (Win64)
4. PHP 5.5.12
5. MySQL 5.6.17
6. Green
7. One line, "127.0.0.1 localhost" without quotes and active (no pound sign)
8. Yes
9. Yes
10.Below...
11. MSE
12. C:\wamp

I am attempting to verify I have URL rewriting working correctly. So far, I have activated (in Apache) the modules, rewrite_module, headers_module, filter_module.

I also enabled logging in C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf with the line

LogLevel debug rewrite:trace8


I Restarted All Services.

In C:\wamp\www, I have the file 'test.php', below:
<?php

echo "hello world!";

?>
In C:\wamp\www, I have the file '.htaccess', below:

<IfModule mod_rewrite.so>
RewriteEngine on
RewriteRule ^(.*)$ test.php [L]
</IfModule>


I have verified my .htaccess file is getting used by adding garbage to the top of the file. For example, the below produces an Internal Server Error:

AHHHHHHHH
<IfModule mod_rewrite.so>
RewriteEngine on
RewriteRule ^(.*)$ test.php [L]
</IfModule>

I can also find the debug line in the appache_error.log:
[Mon Feb 02 22:33:54.531848 2015] [core:alert] [pid 9228:tid 816] [client 127.0.0.1:58321] C:/wamp/www/.htaccess: Invalid command 'AHHHHHHHH', perhaps misspelled or defined by a module not included in the server configuration

When I navigate to "[127.0.0.1];, the file test.php is not served. Instead, I receive a 404 Not found error:
The requested URL /foobar.php was not found on this server.

I am not receiving a pass-through log message of any kind which would indicate the match statement is found or rewrite rule occurring. Here are the last few lines of my apache_error.log after visiting the navigating to the URL above:
[Mon Feb 02 22:43:49.577883 2015] [authz_core:debug] [pid 9228:tid 816] mod_authz_core.c(799): [client 127.0.0.1:58391] AH01626: authorization result of Require all granted: granted
[Mon Feb 02 22:43:49.577883 2015] [authz_core:debug] [pid 9228:tid 816] mod_authz_core.c(799): [client 127.0.0.1:58391] AH01626: authorization result of <RequireAny>: granted
[Mon Feb 02 22:43:49.579883 2015] [:error] [pid 9228:tid 816] [client 127.0.0.1:58391] script 'C:/wamp/www/foobar.php' not found or unable to stat

What am I doing wrong/why isn't he test.php being served?

Options: ReplyQuote
Re: Simple mod_rewrite test
Posted by: RiggsFolly (---.as43234.net)
Date: February 03, 2015 09:49AM

Hi A,

Url rewriting works just fine. So it must be something wrong with your RewriteRule.

Sorry, I am no expert on those.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.