How to change this so I don't have to list every folder/file I want access to?
Here's what I'm currently using.
RewriteCond $1 !^(index\.php|admin|adminmvc|common|contentimg|css|scripts|lib|parts|pages|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Currently I have to manually list the exact files/folders that I don't want to be redirected.
I want any path that doesn't exist to be sent to index.php
Any folders or files that do exist should go to the requested location without me having to list each one in the .htaccess
[resolved] Apache rewrite for front-controller
Moderator: General Moderators
-
thinsoldier
- Forum Contributor
- Posts: 367
- Joined: Fri Jul 20, 2007 11:29 am
- Contact:
[resolved] Apache rewrite for front-controller
Last edited by thinsoldier on Wed Jun 23, 2010 2:20 pm, edited 1 time in total.
Warning: I have no idea what I'm talking about.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Apache rewrite for front-controller
Check the mod rewrite docs. -d is a dir and -f a file. Use one or both:
[text]RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f[/text]
[text]RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
thinsoldier
- Forum Contributor
- Posts: 367
- Joined: Fri Jul 20, 2007 11:29 am
- Contact:
Re: Apache rewrite for front-controller
Thanks
And I can have somewhat separate sites under the /admin/ and /employees/ directories, each with their own front controller (and the same .htaccess rules in each directory)
Code: Select all
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
# RewriteRule . /index.php [L]
RewriteRule ^(.*)$ /index.php/$1 [L]Which means http://www.example.com/news/view/336/ becomes http://www.example.com/index.php/news/view/336/www.chrisabernethy.com wrote:In the preceding example, the rewrite engine is enabled, and two conditions are used to determine whether or not to run the rewrite rule. The first checks to see if the requested resource is not a file, and the second checks to see if the requested resource is not a directory. If both checks pass (ie: the resource does not exist), the rewrite rule will be executed and the file '/index.php' will be served. Depending on what your application requires, your actual rewrite rule may differ slightly. For example, the Zend Framework requires that the original request be fed back into the central dispatch file like this:
RewriteRule ^(.*)$ /index.php/$1
And I can have somewhat separate sites under the /admin/ and /employees/ directories, each with their own front controller (and the same .htaccess rules in each directory)
Warning: I have no idea what I'm talking about.