Skip to content

Instantly share code, notes, and snippets.

@dr-dimitru
Last active April 2, 2018 22:05
Show Gist options
  • Save dr-dimitru/7235754 to your computer and use it in GitHub Desktop.
Save dr-dimitru/7235754 to your computer and use it in GitHub Desktop.
.htaccess file for Laravel 4 and Laravel 3 | For root/ folder
# ----------------------------------------------------------------------
# ROOT/ folder .htaccess
# ----------------------------------------------------------------------
# Laravel Note:
# Note: Laravel is designed to protect your application code,
# and local storage by placing only files that are necessarily
# public in the public folder. It is recommended that you either
# set the public folder as your site's documentRoot (also known as a web root)
# or to place the contents of public into your site's root directory
# and place all of Laravel's other files outside the web root.
# ----------------------------------------------------------------------
# If you have no idea or no possibility to edit server's
# settings (for example at shared hosting) - This .htaccess file
# will do all work for you.
# Just place it into /root folder of your Laravel powered application
# ----------------------------------------------------------------------
# This file works with Laravel 3 and 4
# ----------------------------------------------------------------------
# This .htaccess file is recommended
# to be placed into /root folder of
# your Laravel powered application
# ----------------------------------------------------------------------
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond /public/%{REQUEST_URI} -d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /public/$1/
RewriteBase /
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1
RewriteBase /
RewriteRule ^(/)?$ /public/index.php [L]
@dr-dimitru
Copy link
Author

@Arunmainthan
Yes,
here we put all requests (all URLs) to /public/index.php file.
All URLs which somewhy have /public/ or /public/index.php we rewrite to /, like: mystie.com/public/post/11 will be rewritten to mystic.com/post/11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment