Hot answers tagged .htaccess
The recommendation from the Apache project is: In general, you should only use .htaccess files when you don't have access to the main server configuration file. ... a common misconception is that user authentication and mod_rewrite directives must go in .htaccess files. So please both set AllowOverride None and all your other directives in the main ...
It doesn't seem that you want to access anything outside of the /public folder? If so, this seems easy to me, and without any rewrites (I hope there isn't any reason you actually want to use mod_rewrite!) Put index.php in the public folder Set the DocumentRoot to be the public folder Use ErrorDocument to redirect any file not found to index.php If you ...
I would implement these kind of redirects in the application code itself, creating an array with source and destination URLs, and then testing if the URL contains params in the array, send back a redirect to destination. Using rewrite rules for this is a bit complicated way to implement this.
Your use-case is the text-book example of when to completely avoid rewrite rules. To redirect http URLs to https, simply do the following: <VirtualHost *:80> ServerName www.example.com Redirect "/" "https://www.example.com/" </VirtualHost> <VirtualHost *:443> ServerName www.example.com # ... SSL configuration goes here ...
You will need to have an active vhost serving the domain you want to redirect, even if not in use. It will work absolutely fine in the httpd.conf file, Apache is set to read from all *.conf files.
Only top voted, non community-wiki answers of a minimum length are eligible