How to tell if .htaccess is working?


Newbie question here… I’ve placed an .htaccess file in my document root (alongside index.php - right?) which contains

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/test$ /index.php

but when I go to http://[mydomain]/test I get a 404 message: The requested URL /test was not found on this server.

I must be failing to understand something fundamental. How can I check .htaccess is doing anything?


Read the documentation for RewriteRule directive again:

o When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the RewriteRule pattern matching and automatically added after any relative (not starting with a slash or protocol name) substitution encounters the end of a rule set. See the RewriteBase directive for more information regarding what prefix will be added back to relative substitutions.
o If you wish to match against the full URL-path in a per-directory (htaccess) RewriteRule, use the %{REQUEST_URI} variable in a RewriteCond.
o The removed prefix always ends with a slash, meaning the matching occurs against a string which never has a leading slash. Therefore, a Pattern with ^/ never matches in per-directory context.


Worked like a charm. Now to get to grips with those regexes, something I usually try to avoid.

Many thanks for the quick and accurate response!