# Redirect all web traffic into the Laravel public/ directory so the site can be
# accessed without appending /public to the URL (e.g. http://localhost/1smm
# instead of http://localhost/1smm/public). Laravel's own public/.htaccess then
# handles the front-controller (index.php) routing.
#
# IMPORTANT: the project lives in the "1smm" subfolder under the web root, so the
# file-existence checks below are rooted at /1smm/public. Adjust the "/1smm"
# segment if you deploy somewhere else (or, better, point the vhost DocumentRoot
# at the public/ folder — see deployment/).

<IfModule mod_rewrite.c>
    RewriteEngine On

    # 1) Requests that map to a real file or directory inside public/ are served
    #    directly (assets, images, the storage junction, etc.). This avoids the
    #    double-rewrite that would otherwise strip the route path.
    RewriteCond %{REQUEST_URI} !/public/
    RewriteCond %{DOCUMENT_ROOT}/1smm/public/$1 -f [OR]
    RewriteCond %{DOCUMENT_ROOT}/1smm/public/$1 -d
    RewriteRule ^(.*)$ public/$1 [L]

    # 2) Everything else is routed through the front controller. The original
    #    path is appended as PATH_INFO (public/index.php/$1) so Laravel resolves
    #    the correct route (e.g. /sms) instead of collapsing to "/".
    RewriteCond %{REQUEST_URI} !/public/
    RewriteRule ^(.*)$ public/index.php/$1 [L]
</IfModule>

# Deny web access to sensitive files at the project root.
<FilesMatch "^\.env|composer\.(json|lock)|\.git">
    Require all denied
</FilesMatch>
