Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-17-2013, 07:27 PM   PM User | #1
FCM
New to the CF scene

 
Join Date: May 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
FCM is an unknown quantity at this point
multiple directory rerouting using rewrites

I'm trying to rewrite multiple directories for my app using .htaccess

All requests are processed via the 'app.php' file in my 'Web' directory which works absolutely fine but I've got my assets (CSS/JS/Images) in the 'Assets' folder but I want to be able to access them by pointing to 'css/filename.css'. The 'Assets' folder is outside the 'Web' directory

If I try adding a anything to the root .htaccess telling the server rewrite requests with a '.css' or '.js' extension to the appropriate location in the 'Assets' folder, then the rewrite that sends all other requests to the 'app.php' file in the 'Web' directory stops working altogether.

Requests:
Code:
http://localhost/page -> /htdocs/Web/app.php
http://localhost/css/filename.css -> /htdocs/Assets/CSS/filename.css
http://localhost/js/filename.js -> /htdocs/Assets/JS/filename.js
Structure:
Code:
htdocs
- .htaccess

- Assets
-- CSS
--- file.css
-- Images
-- JS

- Web
-- .htaccess
-- app.php
/htdocs/.htaccess:
Code:
<IfModule mod_rewrite.c>
    #CSS
    RewriteCond %{REQUEST_URI} \.(css)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^css/(.*) Assets/CSS/$1 [L]

    RewriteRule .? - [S=2]

    #Reroute to app
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^$ Web/ [L]
    RewriteRule (.*) Web/$1 [L]
</IfModule>
/htdocs/Web/.htaccess
Code:
<IfModule mod_rewrite.c>
    DirectoryIndex app.php

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !\.(css)$
    RewriteRule ^(.*)$ app.php?$1 [PT,L]
</IfModule>
Thank you very much for your help!
FCM is offline   Reply With Quote
Reply

Bookmarks

Tags
apache, htaccess, mod_rewrite

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:59 AM.


Advertisement
Log in to turn off these ads.