I have a site that evaluates any URL against their database and redirects accordingly to a php content or a default 404 page.
To develop a beta site, and add other folder for different purposes, I'd like to add these folders
example.com/beta
example.com/products/
example.com/photos
as exceptions in the HTACCESS file. Meaning, the site should read/render the content that is in these folders! Instead of redirecting OR producing content based on the main index (sample.com/index.php
). Right now I can't access any files in example.com/beta/
Used all the answers found in StackOverflow: Exclude one folder however, all the answers had the unfortunate effect of breaking the whole site instead of just adding exceptions OR sends me to the default 404 page (the "exception" folders ALREADY have index files, 404 should not happen)
Adding any of the following answers, just below the first RewriteEngine on
didn't work:
...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule !^beta($|/) http://www.example.com%{REQUEST_URI} [L,R=301]
...
</IfModule>
OR
...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(beta) - [L]
...
</IfModule>
OR
...
<IfModule mod_rewrite.c>
RewriteEngine On RewriteCond %{REQUEST_URI} !^/uploads/
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
...
</IfModule>
At this point I am scratching my head as to what rule am I writing wrong to make the folder exceptions work. Below is the complete (original htaccess) file
Original HTACCESS
<IfModule mod_headers.c>
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2020 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^((.)?)$ index.php?p=home [L]
RewriteCond $1 /var/www/vhosts/mywebsite.com/httpdocs
RewriteRule ^(.+)$ / [L]
RewriteCond $1 !^(\#(.)*|\?(.)*|index\.php(.)*|content\/(.)*|css\/(.)*|picture_library\/(.)*|img\/(.)*|readme\.txt(.)*|favicon\.ico(.)*|robots\.txt(.)*|download\.php(.)*|admin\.php(.)*|\.htaccess\.back(.)*|\.htaccess(.)*|external\-export\.php(.)*|login\.php(.)*|cgi-bin\/(.)*|ioncube\/(.)*|test\/(.)*|sitemap\.xml(.)*|old\/(.)*|index\.php\?p\=404(.)*|C079CC0215D2E77B89B0F1837C8199B1\.txt(.)*|images\/(.)*|index\.html(.)*)
RewriteRule ^(.+)$ index.php?url=$1&%{QUERY_STRING} [L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,L]
</IfModule>
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|ico|flv|jpg|jpeg|png|gif)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>