mod_rewrite - RewriteRule - redirecting to index not showing css,images,etc
Your rules should use conditions to exclude real files or directories.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([A-Za-z0-9]+)/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9]+)$ /$1/ [L]
Images can not be found after using mod_rewrite
Relative URLs are now resolved from /solutions/hardware.html
and not /page.php?ida=solutions&idb=hardware
. That means a reference with a relative URL path like images/foobar
would be resolved to /solutions/images/foobar
and not to /images/foobar
.
Just use absolute URL paths like /images/foobar
to reference your external resources and the references are independent from the path of your base URL.
Images can not be found after using mod_rewrite
Relative URLs are now resolved from /solutions/hardware.html
and not /page.php?ida=solutions&idb=hardware
. That means a reference with a relative URL path like images/foobar
would be resolved to /solutions/images/foobar
and not to /images/foobar
.
Just use absolute URL paths like /images/foobar
to reference your external resources and the references are independent from the path of your base URL.
Using mod_rewrite to access images better?
In your web_root folder add an .htaccess file and include the next rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^images/(.*) http://%{HTTP_HOST}/inc/images/$1 [R=301,L]
</IfModule>
I did it and it worked for me.
Hope i help you
.htaccess mod_rewrite image/css/js URLs to template folder
If everything that begins with /static/
should be rewritten, you can use this:
RewriteEngine on
RewriteRule ^static/.+ /application/templates/some_template/$0
after using mod_rewrite link are not found
So you want the assets to be requested correctly? I guess you're using incorrect relative paths for linking those in your page's code (something like "images/image.jpg"..). If that's the folder structure you have, try to go one level up and use this path:
<img src="../admin/images/image.jpg" ...
or, in the case you specified:
<link href="../admin/css/style.css" ...
Will mod_rewrite to an image on another domain cost bandwidth for the original domain?
Your rule will result in a response that tells the client to send another to the target location to retrieve the resource from there (see HTTP response status code 302).
Only if you’re using a proxy (using the P flag, see also mod_proxy) your server would request the resource from remote and pass it to the client, resulting in doubling the in- and output.
Related Topics
Adding CSS Class to Multiple Elements
How to Use Nth-Child in CSS to Select All Elements After The 3Rd One
Firefox Not Recognizing a Font
Left/Right Float Button Inside Div
What Is a Good CSS Cleanup Tool
How to Add a Svg as Content on: Before Pseudo Element of an Element
Change Font Sizes with Style Sheets for Rstudio Presentation
Bootstrap 3.0 - Vertically Align 3 Panels in The Same Row (Auto Height)
Em Vs Px... for Mobile Browsers
Generate Random Color with Pure CSS (No JavaScript)
Using Cors Headers with CSS Background-Image
CSS3 Button Background Color Infinite Transition
CSS Apply Border to a Cloud Shape