mod_rewrite重定向发送状态代码 500


mod_rewrite redirect sends status code 500

>我目前正在使用此.htaccess

RewriteEngine on
RewriteRule ^profile/([^/.]+)/?$ p.php?un=$1 [L]

它运行良好,可以从

p.php?un=2 to profile/Eddy

但是当我将其添加到代码中以从品牌.php?b=3 重定向到品牌/名称

RewriteRule ^brand/([^/.]+)/?$ brand.php?b=$1 [L]

它始终发送状态/错误代码 500。

你可以试试这个小得多的.htaccess:

# multiple file types
<FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
 Order Allow,Deny
 Deny from all
</FilesMatch>                   
AddHandler application/x-httpd-php54  .php54 .php
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/php
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine on
RewriteBase /
# proc/self/environ? no way!
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|'%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|[|'%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|[|'%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^ index.php [F,L]
RewriteCond %{HTTP_HOST} ^www'.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s([^.]+)'.php [NC]
RewriteRule ^ %1 [R,L,NE]
RewriteRule ^profile/([^/.]+)/?$ p.php?un=$1 [L,QSA,NC]
RewriteRule ^brand/([^/.]+)/?$ brand.php?b=$1 [L,QSA,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1'.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
你有几个

问题.htaccess!文件开头为:

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /

下一部分的前 2 行有什么用?

RewriteCond %{HTTP_HOST} ^www'.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.servicebox.com.ng [NC]
RewriteRule ^(.*)$ http://servicebox.com.ng/$1 [L,R=301]

这里应该来自上面的规则(可能仍然不起作用)

RewriteRule ^profile/([^/.]+)/?$ p.php?un=$1 [L]
RewriteRule ^brand/([^/.]+)/?$ brand.php?b=$1 [L]

最后的所有其他内容:

# hide .php extension
#To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s([^.]+)'.php [NC]
RewriteRule ^ %1 [R,L,NC]
#To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
ErrorDocument 400 http://www.servicebox.com.ng/400
#All other ErrorDocuments... and following non related stuff