soycharliente Posted April 15, 2010 Share Posted April 15, 2010 I'm copying this code from one server to another. Works fine on the first and causes a 500 internal server error on the second. Can anyone help me figure out why? Something I'm not seeing? I checked from extra keystrokes when transferring. This is driving me crazy. .htaccess RewriteEngine On Options +FollowSymlinks Options All -Indexes RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC] RewriteRule ^(.*) http://domain.tld/$1 [L,R=301] Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 15, 2010 Share Posted April 15, 2010 If you check the web server's error log you will probably get more information, but that error is usually because mod_rewrite is not enabled in the httpd.conf Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042469 Share on other sites More sharing options...
soycharliente Posted April 15, 2010 Author Share Posted April 15, 2010 It's on a server at a hosing company. I don't think I can get at that stuff. I know I can upload my own php.ini file. Can I do something in there to help fix the issue? I wonder if mod_rewrite is on for one server and off for another. I'll call them about it too. Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042623 Share on other sites More sharing options...
cags Posted April 15, 2010 Share Posted April 15, 2010 Place all the mod_rewrite related code in an ifmodule like so... <IfModule mod_rewrite.c> # code here </IfModule> If mod_rewrite isn't enabled on the system the 500 server error should disappear. If it doesn't disappear then that is not the problem. Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042632 Share on other sites More sharing options...
soycharliente Posted April 15, 2010 Author Share Posted April 15, 2010 Still 500. <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymlinks Options All -Indexes RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC] RewriteRule ^(.*) http://domain.tld/$1 [L,R=301] </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042638 Share on other sites More sharing options...
cags Posted April 15, 2010 Share Posted April 15, 2010 Hmm... if I use that code (with the address changed on the RewriteCond to my server) with mod_rewrite disabled then nothing happens, if I use it with it enabled then I get redirected to http://domain.tld. Is that the only code in your .htaccess? Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042654 Share on other sites More sharing options...
soycharliente Posted April 15, 2010 Author Share Posted April 15, 2010 Yup. What's the best way to ensure mod_rewrite is enabled? Call my hosting company? Something I can put in my php.ini file? Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042658 Share on other sites More sharing options...
cags Posted April 15, 2010 Share Posted April 15, 2010 You need to check the httpd.conf file, you don't have access so would perhaps have to contact your host, there may be another way, but unlikely if you don't have SSH access. Having said that, I'm fairly confident it must be on since you still get the crash with the ifmodule used. Try using just the following in your .htaccess.... RewriteEngine On ... if you still get a 500 errror, try this... <IfModule mod_rewrite.c> RewriteEngine On </ifModule> ... if you still get an error try an empty .htaccess. I would probably guess at this point that the problem is the two Options directives rather than the mod_rewrite ones. If you try the above two without errors, try just... <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC] RewriteRule ^(.*) http://domain.tld/$1 [L,R=301] </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042663 Share on other sites More sharing options...
soycharliente Posted April 15, 2010 Author Share Posted April 15, 2010 I didn't even think about trying to test the Options. Took those out and it seems to be working perfectly. <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.youspeaktocongress.com [NC] RewriteRule ^(.*) http://youspeaktocongress.com/$1 [L,R=301] </IfModule> ...is what I have now. Well, I was using those Options for something, but since I'm so new to mod_rewrite I forget exactly what they did. Guess this will have to do for now. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042666 Share on other sites More sharing options...
cags Posted April 15, 2010 Share Posted April 15, 2010 The Options directives themselves have nothing to-do with mod_rewrite directly. The first line you have enables FollowSymLinks, which whilst required is probably already enabled. The second line you have enables all the options (thus rendering the first line obsolete) except the Indexes option (which displays a list of contents if a URL to a folder is requested and no DocumentIndex is found). http://httpd.apache.org/docs/1.3/mod/core.html#options NB: If you haven't already (I can't tell as I'm posting), can you please mark the topic solved using the button at the bottom left of the thread. Quote Link to comment https://forums.phpfreaks.com/topic/198647-rewrite-causes-500-internal-error/#findComment-1042669 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.