2

I am facing a problem, the mapping of my site looks like this:

- app
- bootstrap
- public_html
  - archives
  - css
  - js
  index.php
- vendor
composer.json
etc...

My .htaccess is located in public_html. I want to skip the directory public_html/archives from the whole framework. How would I do that? I want the route mysite.com/archives to be accessible outside Laravel.

Edit: Here is my htaccess file

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} "/public/archives/" <--- ADDED!
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

4
  • 1
    Have you tried it? Because with the default .htaccess Laravel doesn't run on requests to files or directories that actually exist. Commented May 3, 2015 at 18:45
  • I have tried a lot of things with the .htaccess file, but it doesn't seem to work. Commented May 3, 2015 at 19:04
  • @Displee - please share the content of your .htaccess file. Have you made in changes to the file? Commented May 4, 2015 at 4:49
  • I have added my htaccess file to the main post, sorry for the late reply. Commented May 9, 2015 at 19:43

1 Answer 1

1

As others have noted, Laravel won't process any files or directories that exist because of the following rules:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

First, take this rule out of your .htaccess file:

RewriteCond %{REQUEST_URI} "/public/archives/"

Then, after the RewriteEngine On line, you need to add this rule:

RewriteRule ^archives/?$ - [PT]

So your .htaccess file will look like this:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteRule ^archives/?$ - [PT]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Alternatively, you can just add the following line before RewriteCond %{REQUEST_FILENAME} !-d:

RewriteCond %{REQUEST_URI} !^/archives/?.*$
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.