Link to home
Start Free TrialLog in
Avatar of SheppardDigital
SheppardDigital

asked on

.htaccess redirect if file exists

Hi,

I'm hoping this is an easy one but I can't figure it out.

Here's my current .htaccess file

RewriteEngine on

# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]

# Handle redirection to routes
RewriteRule     ^public/(.*) app/routes/public/www/$1 [L]
RewriteRule     ^admin/(.*) app/routes/admin/www/$1 [L]

# Handle framework requests
RewriteRule ^(.*)$ framework/index.php$1  [L]

Open in new window


On these lines,
RewriteRule     ^public/(.*) app/routes/public/www/$1 [L]
RewriteRule     ^admin/(.*) app/routes/admin/www/$1 [L]
How do I set these to only redirect if the requested file actually exists at the new location? Otherwise continue to process the rest of the .htaccess file?

Bascially, I don't want to redirect /admin/ to app/roues/admin/www/ but /admin/css/style.css should redirect to app/routes/admin/www/css/style.css ok as it's an actual file.
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial