Apache 重写规则在.htaccess中不起作用

Apache 重写规则在.htaccess中不起作用,apache,.htaccess,seo,Apache,.htaccess,Seo,我有下面的.htaccess,我平淡无奇地试图对我网站的url进行SEO描述 RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www.)?mysite.com/.*$ [NC] #RewriteRule .(gif|jpg|swf|flv|png)$ /feed/ [R=302,L] AddDefaultCharset utf-8 <ifModule mod_gzip.

我有下面的.htaccess,我平淡无奇地试图对我网站的url进行SEO描述

RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mysite.com/.*$ [NC]
#RewriteRule .(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
AddDefaultCharset utf-8

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=37739520, public"
</FilesMatch>

#RewriteCond /%{REQUEST_FILENAME}.php -f

#Redirige con un 302 tutte le richieste da pagine HTML a pagine php
RewriteRule (.*).htm$ /$1.php [R=301,L]

ErrorDocument 400 /errore/errore.php?error=400&url=%{HTTP_REFERER}
ErrorDocument 401 /errore/errore.php?error=401&url=%{HTTP_REFERER}
ErrorDocument 403 /errore/errore.php?error=403&url=%{HTTP_REFERER}
ErrorDocument 404 /errore/errore.php?error=404&url=%{HTTP_REFERER}
ErrorDocument 500 /errore/errore.php?error=500&url=%{HTTP_REFERER}


RewriteEngine On    

#-------------------------------
#Fix Language subfolders
#-------------------------------
#empty url -> redirect to it/
RewriteCond %{QUERY_STRING} !lang=(it|en)
#RewriteRule ^$ it/ [R=301,L]

#url is language made by 2 chars like '/it' or '/en' -> redirect to /it/ or /en/ (adding slash)
RewriteRule ^([a-zA-Z]{2})$ $1/ [R=301,L]

# now all urls 2 chars long -> parse them
# old RewriteRule ^([a-zA-Z]{2})$  /$1/ [QSA]
RewriteRule ^([a-zA-Z]{2})/(.*)$  /$2?lang=$1&%{QUERY_STRING} [QSA]

#-------------------------------
# SEO rescripting
#------------------------------- 
RewriteRule ^partita/(.*)$ /analizza-partita.php?partita=$1&%{QUERY_STRING} [L,QSA]
RewriteRule ^statistiche/partita/(.*)$ /analizza-partita.php?partita=$1&%{QUERY_STRING} [L,QSA]    
RewriteRule ^squadra/(.*)$ /team/$1 [L,QSA]
RewriteRule ^team/(.*)$ /squadra.php?id=$1&%{QUERY_STRING} [L,QSA]    
有了这个,我总是遇到404错误,而不是预期的:

www.mysite.com/squadra.php?lang=it&id=12345

天哪,为什么?

您的问题似乎是由于选项
多视图造成的

使用.htaccess顶部的此行将其关闭:

Options -MultiViews

选项
MultiViews
(请参阅)由
Apache的内容协商模块
使用,该模块在
mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。因此,如果
/file
是URL,那么Apache将提供
/file.php

squadra.php,并且它存在于根文件夹中。那么
www.myste.com/squadra.php?lang=it&id=12345
在浏览器中工作正常吗?你的规则对我的Apache很管用是的,很管用。这就是为什么我不明白原因。而且我不明白为什么“团队”有效,但“斯奎德拉”不行!我还尝试添加另一个相同的规则,更改关键字“squadra”,如下面所示,它可以工作!重写规则^pippo/(.*)$/team/$1[L,QSA]YEEES,这就是问题所在。它现在可以正常工作了!非常感谢。
Options -MultiViews