1

我有这个作为我的.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]

我试图制作干净的网址,重定向daltonempire.nl/users/Medaltonempire.nl/users.php?user=Me.

然而,我惨败。我的网站现在不断返回一个500 Internal Server Error. (我可能以某种方式创建了一个重定向循环?)

我做错什么了?(我该怎么做才能修复它?)

4

1 回答 1

1

相信你在最后一条规则中有一个额外的换行符。还要确保L在所有规则中使用 (Last) 标志。

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]
于 2013-10-14T15:09:13.417 回答