Hi

I was searching your form and came a cross a post that showed this code to set up 301 Redirect

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^tomorrownextweek\.com [NC]
RewriteRule ^(.*)$ http://www.tomorrownextweek.com/$1 [L,R=301]

Note I changed the web site to mine.

The problem I'm having is I'm getting a 500 error and it kills my web site when I load my .htaccess file

any ideas why

Dani AI

Generated

A few focused points that address the 500 error and give a correct non‑www 301 redirect.

The 500 shows Apache rejected something in the .htaccess (syntax, a disallowed directive, or a missing module). and pointed to host/server differences — that is the right direction. Below is a safe, minimal redirect that enforces non‑www (replace example.com with your domain), followed by practical troubleshooting steps.

# enforce non-www canonical host
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

What to do if that still breaks the site:

  • Check Apache error_log for the exact error message; it tells whether a particular command is invalid or a module is missing.
  • Test with a temporary redirect first (R=302) to avoid cached 301 behavior while debugging, then switch to 301 when verified.
  • Ensure the file is saved without a UTF‑8 BOM and with UNIX line endings; stray invisible bytes can trigger a 500.
  • Confirm file permissions and ownership are reasonable (typically 644) so Apache can read .htaccess.
  • If on shared hosting, ask support whether per‑directory overrides are allowed and whether the rewrite engine is enabled; if you control Apache config, place redirects in the VirtualHost rather than .htaccess for better performance.
  • After changes, clear browser cache or test with curl/wget to avoid cached redirect results.

For authoritative reference on syntax and allowed contexts, consult the Apache mod_rewrite and .htaccess documentation:
mod_rewrite documentation
Using .htaccess files

This keeps things aligned with ’s goal (non‑www canonicalization) while addressing the typical causes and observed.

Recommended Answers

All 2 Replies

Your host may not allow you to use .htaccess or mod_rewrite.

proc

Try removing this line...
Options +FollowSymLinks

Our Linux server has mod-rewrite turned on but it hates that line. Works great without it.

Julie

Hi

I was searching your form and came a cross a post that showed this code to set up 301 Redirect

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^tomorrownextweek\.com [NC]
RewriteRule ^(.*)$ http://www.tomorrownextweek.com/$1 [L,R=301]

Note I changed the web site to mine.

The problem I'm having is I'm getting a 500 error and it kills my web site when I load my .htaccess file

any ideas why

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.