2

I've got this as my .htaccess:

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html

# Where it's all about
RewriteRule ^users/([a-zA-Z0-9]+)$ users.php?user=$1
RewriteRule ^users/([a-zA-Z0-9]+)/$ users.php?user=$1

RewriteEngine On
RewriteCond %{HTTP_HOST}  ^www.daltonempire.nl [nocase]
RewriteRule ^(.*) 
http://daltonempire.nl/$1 [last,redirect=301]

I tried to make clean urls, redirecting daltonempire.nl/users/Me to daltonempire.nl/users.php?user=Me.

However, I failed miserably. My website now constantly returns a 500 Internal Server Error. (I possibly somehow created a redirection loop?)

What did I do wrong? (And what do I have to do to fix it?)

Isaiah
  • 1,852
  • 4
  • 23
  • 48

1 Answers1

1

Believe you have an extra newline in last rule. Also make sure to use L (Last) flag in all of your rules.

RewriteEngine on 

# Where it's all about
RewriteRule ^users/([a-zA-Z0-9]+)/?$ users.php?user=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f    
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.+?)/?$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} !-f    
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.+?)/?$ $1.html [L]

RewriteCond %{HTTP_HOST} ^www\.(daltonempire\.nl)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301,NE]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • That does solve the 500 Error for my whole website. However, I still get the 500 error when I go to `daltonempire.nl/users/me` (which _should_ redirect me to `daltonempire.nl/users.php?user=me`) Aside from that, what does the `L` flag then do? – Isaiah Oct 14 '13 at 15:20
  • Thank you! (But still, what does the `L` flag do?) – Isaiah Oct 14 '13 at 15:43
  • You're welcome. `L` is for Last rule that injects the resulting URI again for Apache to evaluate. – anubhava Oct 14 '13 at 15:43