emotn,
No problem! I'm glad that the tutorial has helped another SitePoint member.
I'm a bit concerned over your no .asp, no redirection as that's just not true! First, mod_rewrite only matches the pattern in the regex of the URI then effects a redirection as specified. The power of regular expressions means that you can build complex patterns to exactly match specific URIs. In your case, redirecting from a X.asp URI to X.php is trivial (you nailed that one). There is nothing in your code that says that either X.asp file or X.php file has to exist.
If you need to ensure that either is a file which exists, you can use RewriteCond %{REQUEST_FILENAME} -f or modify %{FILENAME} to provide the path from the physical root to the file, i.e., %{DOCUMENT_ROOT}X.asp or %{DOCUMENT_ROOT}.php - but that's another subject.
If you want to redirect to a "pretty URI," do it before redirecting to the .php version, i.e., X.asp => X => X.php. In the first redirection, make the redirection with the R=301 flag then Chain to X => X.php with only the Last flag. Problem (redirect from ASP scripts to a pretty URI then serve the PHP script) resolved! It's not magic (other than the regex), it's merely thinking about the problem logically then generating the code.
Regards,
DK
Bookmarks