I am shocking at mod_rewite, here's the scenario:

I need a rule that rewrites mydomain.com to mydomain.com/app/views/home/home.php.

The rule, or set of rules rather, must also rewite mydomain.com/signin to mydomain.com/app/views/signin/signin.php, and work in a similar fashion for any subdirectory, for example: mydomain.com/subdir must redirect to mydomain.com/app/views/subdir/subdir.php.

The rules must also work with or without the trailing slash, for example: ….com or ….com/.

Thank you all, your help is much appreciated!

If you could outline how and why your solution works or direct me to a good resource that explains it, I'd be exceptionally grateful!

Edit: I have got a simple .htaccess file with this:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^$ http://mydomain.local/~Jay/some_awesome_app/app/views/home/home.php

This does the redirect but changes the URL in the address bar too! I've not got a trailing [R] flag so why would this be?

  • Solved the Edit: should read `RewriteRule ^$ /~Jay/some_awesome_app/app/views/home/home.php – Jonathon David Oates Feb 11 '11 at 14:05
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^$ /~Jay/awesome_app/app/views/home/home.php [L]
RewriteRule ^([a-z0-9_]+)/?$ /~Jay/awesome_kindle_app/app/views/$1/$1.php [L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.