Jump to content

Rewrite causes 500 internal error


soycharliente

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.