我对我的htaccess有以下规则
RewriteRule ^(el|en)/(.*).html/?$ article.php?lang=$1&url=$2 [L,NC,QSA]
当用户前往
时www.mydomain.com/en/this-is-an-article.html
规则转发给article.php并显示页面。
问题是有时规则失败而不是转到
www.mydomain.com/en/this-is-an-article.html
进入
www.mydomain.com/article.php
并且页面未呈现,因为传递的参数未发送且无法处理
如果再次点击查看页面,页面会按预期呈现。
这是我第一次看到类似的东西。
完整的htaccess代码
RewriteEngine on
Options -Indexes
AddDefaultCharset UTF-8
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
# WEEK
<FilesMatch "\.(pdf|swf|js|css|jpg|png|gif|JPG)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl|ttf|woff)$
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>
#fcp.php
RewriteRule ^(el|en)/fcp.php?$ fcp.php?lang=$1 [L,NC,QSA]
#tuner.php
RewriteRule ^(el|en)/index-b/(.*).html/?$ index-b.php?lang=$1&url=$2 [L,NC,QSA]
RewriteRule ^(el|en)/catalog-b/(.*).html/?$ catalog-b.php?lang=$1&url=$2 [L,NC,QSA]
#product.php
RewriteRule ^(el|en)/product/(.*).html/?$ product.php?lang=$1&url=$2 [L,NC,QSA]
#article.php
RewriteRule ^(el|en)/(.*).html/?$ article.php?lang=$1&url=$2 [L,NC,QSA]
#controller.php
RewriteRule ^(el|en)/(.*)/p/([^.]+)?$ controller.php?lang=$1&url=$2&p=$3 [L,NC,QSA]
RewriteRule ^(el|en)/(.*)/?$ controller.php?lang=$1&url=$2 [L,NC,QSA]
#index.php
RewriteRule ^(el|en)?$ index.php?lang=$1 [L,NC,QSA]
任何人都可以提供帮助
答案 0 :(得分:1)
尝试将此代码放在.htaccess:
的顶部# disable MultiViews as it conflicts with mod_rewrite
Options +FollowSymLinks -MultiViews
RewriteEngine on
# skip further rewrites if rewrite has already happened OR else
# if request is for a valid file/directory
RewriteCond %{ENV:REDIRECT_STATUS} 200 [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]