Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subdirectory URL without trailing slash causes 403 error #19

Closed
erJasp opened this issue Apr 5, 2014 · 4 comments
Closed

Subdirectory URL without trailing slash causes 403 error #19

erJasp opened this issue Apr 5, 2014 · 4 comments

Comments

@erJasp
Copy link
Contributor

erJasp commented Apr 5, 2014

When putting October into a subdirectory, it only works when adding the trailing slash to the URL (http://localhost/october/). The URL without trailing slash (http://localhost/october) will display a 403 error or the directory listing.

To fix this issue, add the following to the .htaccess file:

RewriteOptions AllowNoSlash

Info: https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions

When installing to a subdirectory, a RewriteBase should also be set in the .htaccess. It would be great if this could be automated during the install (since it's one of my most heard questions when installing a CMS), but this might as well be just a little note in the installation doc.

@erJasp erJasp changed the title Sub directory URL without trailing slash causes 403 error Subdirectory URL without trailing slash causes 403 error Apr 5, 2014
@daftspunk
Copy link
Member

Thanks for this, I have updated the .htaccess seed file, since the .htaccess file is treated like a config file, it should be updated manually. (The update process will not touch this file)

New contents:

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

    RewriteEngine On

    ##
    ## Directory Listing attempts
    ##
    DirectorySlash Off
    RewriteOptions AllowNoSlash

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

    ##
    ## Handle resource requests
    ##
    RewriteCond %{REQUEST_URI} combine/.*(.css|.js)
    RewriteRule ^ index.php [L]

    ##
    ## White listed folders and files
    ##
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !\.js
    RewriteCond %{REQUEST_URI} !\.ico
    RewriteCond %{REQUEST_URI} !\.jpg
    RewriteCond %{REQUEST_URI} !\.gif
    RewriteCond %{REQUEST_URI} !\.css
    RewriteCond %{REQUEST_URI} !\.less
    RewriteCond %{REQUEST_URI} !\.scss
    RewriteCond %{REQUEST_URI} !\.png
    RewriteCond %{REQUEST_URI} !\.swf
    RewriteCond %{REQUEST_URI} !\.txt
    RewriteCond %{REQUEST_URI} !\.xml
    RewriteCond %{REQUEST_URI} !\.xls
    RewriteCond %{REQUEST_URI} !\.eot
    RewriteCond %{REQUEST_URI} !\.woff
    RewriteCond %{REQUEST_URI} !\.ttf
    RewriteCond %{REQUEST_URI} !\.svg
    RewriteCond %{REQUEST_URI} !docs/.*
    RewriteCond %{REQUEST_URI} !themes/.*
    RewriteRule ^ index.php [L]

    ##
    ## Standard routes
    ##
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

All fixed on my end.

@samgeorges samgeorges added the bug label Apr 6, 2014
@daftspunk
Copy link
Member

Please reopen if this is still occuring.

@RichiUfo
Copy link

i'm sorry but can you help me if i want to add trailing slash to url how my code must look like?

@daftspunk
Copy link
Member

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

No branches or pull requests

4 participants