开发者

Redirects with .htaccess stops images from loading

开发者 https://www.devze.com 2023-02-13 03:24 出处:网络
OK So I\'m looking to redirect the following: http://www.example.org/tag/code To the following: http://www.example.org/tag.php?tag=code

OK So I'm looking to redirect the following:

http://www.example.org/tag/code

To the following:

http://www.example.org/tag.php?tag=code

The following regex is a mix of some of the answers to this question which solves the issue:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule (.+)/ $1.php [L,NC]
RewriteRule (.+)/(.+) $1?tag=$2 [L,NC]

However now, when I try and load an image from my server which is within the directory http://www.example.org/img/imagename.png. It gives me a 500 Internal Server Error and when checking the logs I'm given this message:

[Wed Feb 23 12:27:27 2011] [error] [client xx.xx.xx.xx] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

Does anyone know what's going on 开发者_Python百科there?

Thanks


Try:

RewriteRule (.+?)/(.+) $1.php?t=$2 [L,NC]


Above your RewriteRule add these 2 lines:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

These will tell mod_rewrite to ignore actual files and directories. This should fix your /img/ problem.

You shouldn't need RewriteCond $1 (^/include/) with these lines.

To fix the /img folder, try this:

RewriteRule ^file/img/(.*)$ /img/$1 [L]


Have you tried this?

Options +FollowSymLinks RewriteEngine On

RewriteRule (.+)/(.+) $1.php?t=$2 [L,NC]
RewriteRule (.+)/ $1.php [L,NC]
0

精彩评论

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