Inadvertently my htaccess script is changing image URLs so that any image with "portfolio/" in its URL path is adversely affected.
Is there any way to exclude images from that particular rule?
redirect 301 "/sitemap.xml" http://www.example.com/sitemap.php
RewriteEngine On
RewriteCond %{REQUEST_URI} !portfolio/project
RewriteCond %{REQUEST_URI} /.*portfolio/.*$ [NC]
RewriteRule ^(.*)portfolio(.*)$ /$1portfolio/project$2 [R=301,L]
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/sitemap.php
RewriteRule ^(.*)$ /index.php/$1 [L]
For first part (first rewrite rule) try
RewriteCond %{REQUEST_URI} !portfolio/project
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_URI} /.*portfolio/.*$ [NC]
RewriteRule ^(.*)portfolio(.*)$ /$1portfolio/project$2 [R=301,L]
I'm not sure why you use RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
in second rewriterule.
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
means you don't want to change portfolio to portfolio/project for urls ending with some of allowed image extension. [NC]
(case-insensitive) is used to skip JPG, GIF, PnG, etc extensions also
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With