I want my URI to be rewritten from www.mywebsite.com/design/A/B to
www.mywebsite.com?set=A/B
This htaccess script redirect the page requests properly
Options +Indexes
RewriteEngine on
#RewriteBase /
RewriteRule ^design/(.*) design.php?set=$1[L]
However the css and image files do not show up. According to a
debugger I use, one error is that the css is being served as text/
html, not text/css. I think the file equest is being converted to
www.mywebsite.com?set=css/main.css.
to escape the css files from the rewrite, however the css still will
not show up.
Re: mod_rewrite & css
am 21.09.2007 06:28:13 von David McKenzie
design@scottconnery.com wrote:
> I want my URI to be rewritten from www.mywebsite.com/design/A/B to
> www.mywebsite.com?set=A/B
>
> This htaccess script redirect the page requests properly
>
> Options +Indexes
> RewriteEngine on
> #RewriteBase /
> RewriteRule ^design/(.*) design.php?set=$1[L]
>
> However the css and image files do not show up. According to a
> debugger I use, one error is that the css is being served as text/
> html, not text/css. I think the file equest is being converted to
> www.mywebsite.com?set=css/main.css.
>
> I have tried
>
> Options +Indexes
> RewriteEngine on
> AddType application/x-shockwave-flash .swf
> AddType image/x-icon .ico
> AddType text/css .css
> #RewriteBase /
> RewriteRule ^design/(.*) design.php?set=$1
>
> to force the file types and tried
>
> Options +Indexes
> RewriteEngine on
> AddType application/x-shockwave-flash .swf
> AddType image/x-icon .ico
> AddType text/css .css
> #RewriteBase /
> RewriteRule ^.+(/css/main\.css)$ $2
> RewriteRule ^design/(.*) design.php?set=$1 [L]
>
> to escape the css files from the rewrite, however the css still will
> not show up.
>
Where's the CSS file located?
--
DM davidm@cia.com.au
'It would go against respecting principles and truth if you have to
respect and accept anything just because it is the other side's view.'
- Kim Jung Ill
Re: mod_rewrite & css
am 21.09.2007 14:41:22 von scott
On Sep 21, 12:28 am, David McKenzie wrote:
> des...@scottconnery.com wrote:
> > I want my URI to be rewritten fromwww.mywebsite.com/design/A/Bto
> >www.mywebsite.com?set=A/B
>
> > This htaccess script redirect the page requests properly
>
> > Options +Indexes
> > RewriteEngine on
> > #RewriteBase /
> > RewriteRule ^design/(.*) design.php?set=$1[L]
>
> > However the css and image files do not show up. According to a
> > debugger I use, one error is that the css is being served as text/
> > html, not text/css. I think the file equest is being converted to
> >www.mywebsite.com?set=css/main.css.
>
> > I have tried
>
> > Options +Indexes
> > RewriteEngine on
> > AddType application/x-shockwave-flash .swf
> > AddType image/x-icon .ico
> > AddType text/css .css
> > #RewriteBase /
> > RewriteRule ^design/(.*) design.php?set=$1
>
> > to force the file types and tried
>
> > Options +Indexes
> > RewriteEngine on
> > AddType application/x-shockwave-flash .swf
> > AddType image/x-icon .ico
> > AddType text/css .css
> > #RewriteBase /
> > RewriteRule ^.+(/css/main\.css)$ $2
> > RewriteRule ^design/(.*) design.php?set=$1 [L]
>
> > to escape the css files from the rewrite, however the css still will
> > not show up.
>
> Where's the CSS file located?
>
> --
> DM dav...@cia.com.au
>
> 'It would go against respecting principles and truth if you have to
> respect and accept anything just because it is the other side's view.'
> - Kim Jung Ill
The css file is located at
Root\css\main.css
the .htacess file is at the root as is the script.
Re: mod_rewrite & css
am 21.09.2007 18:26:42 von Jim Hayter
Scott wrote:
>>> to force the file types and tried
>>> Options +Indexes
>>> RewriteEngine on
>>> AddType application/x-shockwave-flash .swf
>>> AddType image/x-icon .ico
>>> AddType text/css .css
>>> #RewriteBase /
>>> RewriteRule ^.+(/css/main\.css)$ $2
What is this rule supposed to do? You are rewriting to $2 but there is
no second parenthesized expression in the line.
>>> RewriteRule ^design/(.*) design.php?set=$1 [L]
>>> to escape the css files from the rewrite, however the css still will
>>> not show up.
Jim
Re: mod_rewrite & css
am 21.09.2007 21:36:13 von HansH
"Scott" schreef in bericht
news:1190378482.554481.166480@57g2000hsv.googlegroups.com...
>> > RewriteRule ^.+(/css/main\.css)$ $2
>> > RewriteRule ^design/(.*) design.php?set=$1 [L]
>>
>> > to escape the css files from the rewrite, however the css still will
>> > not show up.
>>
>> Where's the CSS file located?
>>
> The css file is located at
> Root\css\main.css
> the .htacess file is at the root as is the script.
>
If I understand you correctly, that's like
document_root/
document_root/.htaccess
document_root/design.php
document_root/design/
document_root/css/
document_root/css/main.css
In .htaccess there is no need to exclude some URIs from being rewritten,
unless the resource is below the current folder.
In .htaccess the URI '/css/main.css' is left hand trimmed before processing
to 'css/main.css' and will consequently never match 'RewriteRule
^.+(/css/main\.css)$ $1'. This rule will match on '/design/css/main.css' and
so will the other rule!
The documented syntax for not-rewritting is
RewriteRule regex-to-match-this - [L]
Is your stylesheet linked like this
than try
For further comment show me the tag for a failing image, along
with the URL of the page referring and full local path of both the image and
the html file.
HansH
Re: mod_rewrite & css
am 25.09.2007 14:32:04 von scott
On Sep 21, 3:36 pm, "HansH" wrote:
> "Scott" schreef in berichtnews:1190378482.554481.166480@57g2000hsv.googlegroups .com...>> > RewriteRule ^.+(/css/main\.css)$ $2
> >> > RewriteRule ^design/(.*) design.php?set=$1 [L]
>
> >> > to escape the css files from the rewrite, however the css still will
> >> > not show up.
>
> >> Where's the CSS file located?
>
> > The css file is located at
> > Root\css\main.css
> > the .htacess file is at the root as is the script.
>
> If I understand you correctly, that's like
> document_root/
> document_root/.htaccess
> document_root/design.php
> document_root/design/
> document_root/css/
> document_root/css/main.css
>
> In .htaccess there is no need to exclude some URIs from being rewritten,
> unless the resource is below the current folder.
>
> In .htaccess the URI '/css/main.css' is left hand trimmed before processing
> to 'css/main.css' and will consequently never match 'RewriteRule
> ^.+(/css/main\.css)$ $1'. This rule will match on '/design/css/main.css' and
> so will the other rule!
>
> The documented syntax for not-rewritting is
> RewriteRule regex-to-match-this - [L]
>
> Is your stylesheet linked like this
>
> than try
>
>
> For further comment show me the tag for a failing image, along
> with the URL of the page referring and full local path of both the image and
> the html file.
>
> HansH
the image call is
$page.".jpg) no-repeat'"?>>
aka:
What I would like to do is redirect every call to design.php and set
the query string except those within the images or css directories
Re: mod_rewrite & css
am 25.09.2007 23:45:04 von HansH
"Scott" schreef in bericht
news:1190723524.848095.133070@22g2000hsm.googlegroups.com...
> The structure looks like this:
> document_root/
> document_root/.htaccess
> document_root/design.php
> document_root/css/
> document_root/css/main.css
> document_root/images
>
> The style sheet request is
>
After requesting '/design/page.html' the stylesheet requested is
'/design/css/text-main.css' -check your logs-
Try
> the image call is
>
> url(images/BG".$page.".jpg) no-repeat'"?>>
At first sight the same leading slash should again save the day.
However, images included in style attributes most likely adhere to
http://www.w3.org/TR/CSS1#url: 'Partial URLs are interpreted relative
to the source of the style sheet, not relative to the document:'
Here a partial URL is any URL NOT starting http:, just a leading /
will NOT bring you to the root of the site!
Try
>
adding an additional '../' prefix for each virtual folders below /design.
Alternatively
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^design(/|/.*/)(css|images)/(.*) /$2/$3 [L]
before
RewriteRule ^design/(.*\.html?) design.php?set=$1 [L]
should -as in untested- make mislocated requests for stylesheets and
images read the intended stylesheet or image. The RewriteCond
enables per folder alternates, turning /css.* and /images/*. into globals.
> What I would like to do is redirect every call to design.php and set
> the query string except those within the images or css directories
Either I do not understand you're writings or ...
If you redirect every request, your script will have to pass images too
AND set the content header according to each image type.
Rather limit the parsable requests to .htm(l)
RewriteRule ^design/(.*\.html?)$ design.php?set=$1 [L]
Note the trailing l is optional.
BTW, in general handling .htaccess will give some overhead to the server
reducing performance. To keep this penalty to a minimum move the rewrite
directives from /.htacess to /design/.htaccess and alter them slightly:
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^(.*/)?(css|images)/(.*) $2/$3 [L]
RewriteRule ^(.*\.html?) design.php?set=$1 [L]
It'll save the time to process the directives for each request outside this
branch.