Forums / Developer / RewriteRule help

RewriteRule help

Author Message

Trond Åge Kvalø

Thursday 10 June 2004 7:10:53 am

I tried to use the following rewrite rule on my site:

#RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php

In my site I use an <iframe> for showing a JavaScript based navigation-system (I know, I know....).

When using the above Rewrite rule, I get the site frontpage in the iframe instead of the navigation menu.

I'm no expert on Rewrite rules in Apache, so can anyone please tell me why this happens?

best regards
trondåge

trondåge

Bruce Morrison

Thursday 10 June 2004 4:31:46 pm

Whats the URL used in the iframe?

Cheers
Bruce http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Trond Åge Kvalø

Friday 11 June 2004 1:29:33 am

Hi Bruce.

Here's the beginning of my iframe:

<iframe id="navigationContainer" name="navigationContainer" src="/snakeMenu/snakeMenu.html" 

hmmmm.... perhaps I need to add the /snakeMenu directory to my rewrite rule?

I also have some other nonstandard directories in my eZ publish directory. I have for instance all my javascripts placed in a directory called javascript. Do I need to include those non-standard directories as well?

best regards
trondåge

trondåge

Trond Åge Kvalø

Friday 11 June 2004 5:11:59 am

Ok, after reading a little in mastering Regular Expressions by Jeffrey Friedl (O'Reilly), here's what I've come up with:

If I've understood this correctly "|" means OR inside parenthesis, so the rewrite rule basically states that whenever the beginning of the URL is one of the expressions OR'ed in the first parenthesis, followed by any charachters and then a dot, and the end of URL is one of the expressions in the last parenthesis, the browser is redirected to /index.php

If this is correct, I'm even more puzzled. Because the URL in the iframe shouldn't be redirected then since it's path is not in the first parenthesis.. or am I misunderstanding completely?

best regards
trondåge

trondåge

Tobias Persson

Friday 11 June 2004 5:58:14 am

I think the first '!' mean not

So everything that is do not follow the regular expression gets rewritten to index.php

Trond Åge Kvalø

Friday 11 June 2004 6:06:29 am

Hi Tobias

Why of course, didn't see that because of the line wrapping :-)

So that means that the /snakeMenu directory should be included in the ignored paths, right?

Thanks :-)

best regards
trondåge

trondåge

Tobias Persson

Friday 11 June 2004 6:23:58 am

I think (guess) that you should add ^/snakeMenu in the first parenthes and html to the last one.

Bruce Morrison

Friday 11 June 2004 3:45:27 pm

I find it easiest to add a rewrite rule before that ezpub one.

So you would end up with something like:

RewriteRule /snakeMenu/snakeMenu.html %{DOCUMENT_ROOT}/snakeMenu/snakeMenu.html [L]
RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php

The [L] at the end of the first rule says "Don't process any more rules".

Cheers
Bruce http://www.designit.com.au/

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Trond Åge Kvalø

Tuesday 15 June 2004 5:51:13 am

Thanks for the suggestion Bruce.

But why wouldn't I want to process the last rule? Is it unnecessesary?

best regards
trondåge

trondåge

Bruce Morrison

Tuesday 15 June 2004 4:37:33 pm

The first rule allows requests for the /snakeMenu/snakeMenu.html file to be returned without being passed to ez Publish (index.php). It's basically a pass through rule.

This method allows you to add "pass through" rules without making changes to the standard eZ Publish rule.

I should have added that [L] at the end of the first rules says "if this rule matches, don't process any more rules"

Cheers
Bruce http://www.designit.com.au/

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Trond Åge Kvalø

Thursday 17 June 2004 1:37:07 am

Cheers Bruce!

OK, now I understand. Made a bit of difference the first few words there :-)

Anyway, as I mentioned earlier I have a few other non-standard directories as well. I presume I could just OR these directories together with the snakeMenu directory in the first line to get things right.

Does that sound correct to you?

Best regards
trondåge

trondåge

eZ debug

Timing: Jan 18 2025 23:25:51
Script start
Timing: Jan 18 2025 23:25:51
Module start 'content'
Timing: Jan 18 2025 23:25:52
Module end 'content'
Timing: Jan 18 2025 23:25:52
Script end

Main resources:

Total runtime1.1064 sec
Peak memory usage4,096.0000 KB
Database Queries220

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 587.5938180.8438
Module start 'content' 0.00730.9476 768.4375679.8125
Module end 'content' 0.95490.1514 1,448.2500344.4453
Script end 1.1063  1,792.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.3713210.0002
Check MTime0.00140.1310210.0001
Mysql Total
Database connection0.00130.116510.0013
Mysqli_queries1.000090.38642200.0045
Looping result0.00260.23852180.0000
Template Total1.072496.920.5362
Template load0.00220.202420.0011
Template processing1.070296.727820.5351
Template load and register function0.00020.022110.0002
states
state_id_array0.00220.195410.0022
state_identifier_array0.00220.194920.0011
Override
Cache load0.00200.1789710.0000
Sytem overhead
Fetch class attribute can translate value0.00190.169740.0005
Fetch class attribute name0.00190.1724130.0001
XML
Image XML parsing0.00370.335640.0009
class_abstraction
Instantiating content class attribute0.00000.0037160.0000
General
dbfile0.00570.5182330.0002
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
11content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
22content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 52
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs