Htaccess keep images and css -
i have folder structure this:
- index.php
- css/style.css
- images/image.png
- .htaccess
in htaccess i'd add rules in order create url looks like: home/5/6 goes page: index.php?var1=5&var2=6
doing home/5 index.php?var1=5 works in way it:
rewritecond %{request_uri} !\.(?:css|js|jpe?g|gif|png)$ [nc] rewriterule ^home/(.*)$ index.php?var1=$1 rewritecond %{request_uri} \.(?:css|js|jpe?g|gif|png)$ [nc] rewriterule ^home/(.*)$ $1 [nc,l]
however 2 (or more) variables css , images no longer loading when adding htaccess:
rewritecond %{request_uri} !\.(?:css|js|jpe?g|gif|png)$ [nc] rewriterule ^home/(.*)/(.*)$ index.php?var1=$1&var2=$2 rewritecond %{request_uri} \.(?:css|js|jpe?g|gif|png)$ [nc] rewriterule ^home/(.*)/(.*)$ $2 [nc,l]
in image , css tags use relative paths only.
oke found out of others , here solution:
rewritecond %{request_uri} !\.(?:css|js|jpe?g|gif|png||ttf|woff)$ [nc] rewriterule ^home/(.*)/(.*)$ index.php?var1=$1&var2=$2 [nc,l] rewritecond %{request_uri} \.(?:css|js|jpe?g|gif|png|woff2|ttf|woff)$ [nc] rewriterule ^(.*)/assets/(.*)$ assets/$2 [nc,l]
by knowing of stylesheets, images , other assets located in subfolders inside folder assets, able split rewritten path real path , continue.
thanks though!
Comments
Post a Comment