Skip to content

Instantly share code, notes, and snippets.

@marcosfreitas
Created October 29, 2016 22:04
Show Gist options
  • Save marcosfreitas/037b7d706cd89bbc4b8b9370807378fa to your computer and use it in GitHub Desktop.
Save marcosfreitas/037b7d706cd89bbc4b8b9370807378fa to your computer and use it in GitHub Desktop.
rewrite folder "web/" inside silex
# Project'a Structure
# localhost/projects/myProject/
# -- .htacess
# | -- RewriteEngine On
# | -- RewriteBase /projects/myProject/
# | -- DirectoryIndex web/index.php
# -- src/
# ----- App/
# -- web/
# ----- .htaccess (this file)
# ----- assets/
# ----- index.php (starting silex)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# because of the assets files
RewriteCond %{REQUEST_URI} !^.*\.(jpg|css|js|gif|png)$ [NC]
# Rewriting the base
RewriteRule ^/?$ web/index.php
# "web/" is the public directory inside this project
# Redirect to address without "web/"
RewriteCond %{REQUEST_URI} /web/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
# Rewrite pointing to "web/(...)"
#RewriteRule ^(.*)$ $1 [QSA,L]
DirectoryIndex index.php index.html index.htm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment