Reputation: 772
How would I redirect all files and folders to index with the exception of only a hand full?
Right now I have this, which is redirecting everything, included needed files such as css and js files for site functionality.
RewriteEngine on
RewriteCond %{HTTP_HOST} mysite.com
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php [L,R=301]
Upvotes: 0
Views: 965
Reputation: 896
Try Options -Indexes on the top of htaccess Script
For example if we need to redirect some special extension files to another directory we can implement our htaccess like these
Options -Indexes RewriteEngine on RewriteCond %{REQUEST_FILENAME} .(svc)$ RewriteRule (.fr.*) directoryname/Index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L]
Now all the requests except *.fr will redirect to index.php and *.fr will redirect to the direcoryname/Index.php
Upvotes: 0
Reputation: 831
Try adding the following above the RewriteRule.
RewriteCond $1 !^(cssfolder|otherfolders)
If you would apply the above to your .htaccess, it would like something like:
RewriteEngine on
RewriteCond %{HTTP_HOST} mysite.com
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond $1 !^(cssfolder|otherfolder1|otherfolder2|otherfolder3)
RewriteRule ^(.*)$ /index.php [L,R=301]
Upvotes: 2