![]() |
Rewrite rule generating Internal Server Error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Rewrite rule generating Internal Server Error (/showthread.php?tid=16390) Pages:
1
2
|
Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]johncook[/eluser] I'm trying to rewrite subdomain images: http://subdomain.domain.com/images/pic.jpg >>> http://www.domain.com/images/subdomain/pic.jpg So I tried grabbing the subdomain from the RewriteCond: Code: RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] This generates an Internal Server Error. So I experimented to see what did and didn't work. First to make sure it's working at all, I tried: Code: RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] This works fine - rewrites http://subdomain.domain.com/images/pic.jpg >>> http://www.domain.com/images/pic.jpg. This tells me it's not an error like an infinite loop. Next I tried manually typing in the subdirectory rather than using %1: Code: RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] Again, Internal Server Error. Any clues on what's causing the Server Error? Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]TheFuzzy0ne[/eluser] Is it possible that a directory for that sub domain doesn't exist? Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]TheFuzzy0ne[/eluser] One more thing. What subdomain are you using? If it's not matched by the regex, that could also explain your problem. Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]johncook[/eluser] The directory does exist and does match the regex (as far as I know). An example, the URL is: http://cavaliers.criciwiki.com/images/header.jpg I want it to rewrite to: http://www.criciwiki.com/images/cavaliers/header.jpg Trying both RewriteRule ^images/(.*)$ images/cavaliers/$1 [L] and RewriteRule ^images/(.*)$ images/%1/$1 [L] gives an Internal Server Error. It seems like trying to rewrite to a subdirectory in images is what causes the problem. For the record, rewriting to just the images directory works okay (which confirms the regex matches): RewriteRule ^images/(.*)$ images/$1 [L] Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]Colin Williams[/eluser] [[DELETED]] Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]TheFuzzy0ne[/eluser] Code: RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] I wonder if that will work. I think that paths are somehow the issue here. Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]johncook[/eluser] No, adding the forward slash at the start of the path still gives an internal server error. It does seem to be the path that's an issue. I've tried the following rewrite rule: Code: RewriteRule ^images/(.*)$ %1/$1 [L] This successfully writes subdomain.domain.com/images/pic.jpg to www.domain.com/subdomain/pic.jpg That's not the solution I was after - it needs to be in the images directory. But for some weird reason, it just doesn't want to do it. Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]TheFuzzy0ne[/eluser] It's almost as if the images directory doesn't exist, can you confirm that: a) The directory isn't in fact named "image", and b) The directory permissions are correct. Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]johncook[/eluser] Nothing as simple as typos (I wish it were that although I would be bludgeoning myself with a blunt instrument right now if it were that simple). I know it's not a typo because if I simply remove the %1/ from the rewrite rule, it works. Eg - these rules work: RewriteRule ^images/(.*)$ images/$1 [L] RewriteRule ^images/(.*)$ %1/$1 [L] These rules give a Internal Server Error: RewriteRule ^images/(.*)$ /images/$1 [L] RewriteRule ^images/(.*)$ images/%1/$1 [L] RewriteRule ^images/(.*)$ images/cavaliers/$1 [L] I just checked the permissions and both images/ and images/cavaliers/ have chmod 2777 (eg - read & write permissions are all good to go). I really appreciate all your advice - I'm on the verge of giving up on this though, it just doesn't make any sense. Rewrite rule generating Internal Server Error - El Forum - 03-05-2009 [eluser]TheFuzzy0ne[/eluser] I've been meaning to learn how to write htaccess files for as long as I can remember. I guess now would be the ideal time. So please, bear with me. It's 2AM now, so I figure I've got about 4 hours to see if I can get to the bottom of this for you. |