Please note that the forum isn't realy used anymore.

If you have questions, want support or just simply want to talk to us you can find us on slack.

 

Cannot access subdirectory, 403 forbidden

I am wanting to create a seperate directory for my analytics program to function.

My website is www.loosebruce.co.uk and I want my directory to be accessible as

www.loosebruce.co.uk/analytics

The same way phpmyadmin is accessible with /phpmyadmin

I added the following line to .htaccess file but it is not letting me get into that folder

RewriteRule src/analytics - [PT]

` # follow symlinks & disallow directory listing # note: your hosting company might not allow these directives to be set. In that case, # you should either find another hosting company (advised) or remove the line below. Options +FollowSymlinks -Indexes DirectorySlash Off

# file etags (used when comparing local cached file to server file)
FileETag MTime Size

<IfModule mod_rewrite.c>
    # nice urls
    RewriteEngine On
    RewriteBase /

    # forbidden folders
    RewriteRule .*\.gitignore - [F]
    RewriteRule composer\.json - [F]
    RewriteRule composer\.lock - [F]
    RewriteRule .*\.md - [F]
    RewriteRule src/Frontend/Cache/CachedTemplates - [F]
    RewriteRule src/Frontend/Cache/CompiledTemplates - [F]
    RewriteRule src/Frontend/Cache/Config - [F]
    RewriteRule src/Frontend/Cache/Locale/.*\.php - [F]
    RewriteRule src/Frontend/Cache/Logs - [F]
    RewriteRule src/Frontend/Cache/Navigation/.*\.php - [F]
    RewriteRule src/Frontend/Cache/Search - [F]
    RewriteRule src/Backend/Cache/CompiledTemplates - [F]
    RewriteRule src/Backend/Cache/Config - [F]
    RewriteRule src/Backend/Cache/Cronjobs - [F]
    RewriteRule src/Backend/Cache/Locale/.*\.php - [F]
    RewriteRule src/Backend/Cache/Logs - [F]
    RewriteRule src/Backend/Cache/Navigation - [F]
    RewriteRule src/analytics - [PT]

    #Rewriterule ^analytics/.*$ - [PT]
    #RewriteRule  ^$ /analytics/    [L]
    #RewriteRule  (.*) /analytics/$1 [L]

    # one url to rule them all
    # RewriteCond %{HTTP_HOST} !^www\.<domain>\.be [NC]
    # RewriteCond %{HTTP_HOST} !.*\.dev [NC]
    # RewriteRule ^(.*)$ http://www.<domain>.be/$1 [R=301,L]

    # src dir should pass via the front controller
    RewriteCond %{REQUEST_URI} ^/(src|src\/)$
    RewriteRule . /index.php [NC,L]

    # handle urls
    RewriteCond %{REQUEST_URI} !^$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [NC,L]

    # set environment variable to let PHP know that urls are being rewritten
    RewriteRule .* - [E=MOD_REWRITE:1]
</IfModule>

# file caching in browser
<IfModule mod_expires.c>
    ExpiresActive On
    <FilesMatch "\.(ico|gif|jpe?g|png|svg|svgz|js|css|swf|ttf|otf|woff|eot)$">
        ExpiresDefault "access plus 1 month"
    </FilesMatch>
</IfModule>

# gzip on Apache 2
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml text/javascript text/css application/x-javascript application/xhtml+xml application/javascript

    # these browsers do not support deflate
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html

    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force
</IfModule>

# gzip on Apache 1
<IfModule mod_gzip.c>
    mod_gzip_on Yes

    mod_gzip_item_include mime ^application/javascript$
    mod_gzip_item_include mime ^application/x-javascript$
    mod_gzip_item_include mime ^application/xhtml+xml$
    mod_gzip_item_include mime ^application/xml$
    mod_gzip_item_include mime ^text/css$
    mod_gzip_item_include mime ^text/html$
    mod_gzip_item_include mime ^text/javascript$
    mod_gzip_item_include mime ^text/plain$
    mod_gzip_item_include mime ^text/xml$
    mod_gzip_item_exclude mime ^image/

    # browser issues
    mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
</IfModule>

However I am still denied access, how do I fix this?

I tried to create a folder "test" with an index.html file inside and got a partial success with this:

# nice urls
RewriteEngine On
RewriteBase /

RewriteRule ^(test)/?$ - [L]

The problem is that I can visit www.website.com/test/ but it doesn't work if you forget the slash at the end of the url. Normally the /?$ takes care of this, but it doesn't seem to work.

Hey Jesse,

I decided to upgrade to Apache 2.4 and use its new config features.

I created a config called analytics like so

`

analytics config file allows redirection of /analytics

Alias /analytics /var/analytics

<directory> Options FollowSymLinks</directory>

Disallow web access to directories that don't need it

<directory /> Require all granted `

This now works when navigating /analytics

Comment

The forum is deprecated in favor of our Slack channel, which provides real-time support for your issues.

Join us on Slack here: https://fork-cms.herokuapp.com/