开发者

htaccess block everything but 1 file and 1 folder

开发者 https://www.devze.com 2023-01-25 01:52 出处:网络
I have seen a number of posts similar but wasn\'t able to achieve my actual desired feel. So this is what I have.

I have seen a number of posts similar but wasn't able to achieve my actual desired feel.

So this is what I have. I need to have all my past urls forward t开发者_开发知识库o the INDEX.PHP file. Which is fine and I have that so far, but I need to add an exception of a specific folder the 'images' folder so the images show up, b/c since i'm forwarding everything to the index it's not grabbing all the right images because it is blocking them.

currently I have something like this

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !images/$
RewriteCond %{REQUEST_URI} !index.php$
RewriteRule ^(.*)$ "http://www.exmample.com" [R=301,L]

currently my images won't load unless I do a specific call to the image ie:

RewriteCond %{REQUEST_URI} !images/single/picture.jpg$

Any thoughts or suggestions would be much appreciated. Cheers


Yeah, the "!images/$" means that you're rewriting everything except for the specific request to the URI "http://www.example.com/images/". Use a regular expression in your RewriteCond:

RewriteCond %{REQUEST_URI} !images/(.*)$

This means that no URI starting with "images/" will be rewritten. I guess it'd be safer to do something along the lines of "!images/(.*).jpg$" so that no URIs starting with "\images" and ending with ".jpg" are rewritten. Refine it as needed, i.e. specifying multiple extensions ( (.jpe?g)|(.gif) ).

I'm no mod_rewrite wizard, and I'm not very good at regex, but this approach worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消