我在.htaccess中有这个代码,我需要将此转换为microsoft azure托管,因为它不起作用 .
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php[?/\s]
RewriteRule ^index\.php$ /en/ [R=301,L]
RewriteCond %{THE_REQUEST} /index_cz\.php[?/\s]
RewriteRule ^index_cz\.php$ /cz/ [R=301,L]
RewriteRule ^/en/?$ index.php [NC,L]
RewriteRule ^cz/?$ index_cz.php [NC,L]
有人能帮帮我吗?多谢你们
2 回答
您需要在适当的部分中使用重写规则创建web.config .
我从http://htaccesstowebconfig.com/生成了以下内容
整个web.config文件看起来与此类似
我构建了一个简单的PHP项目来模拟重写规则的情况 .
根目录:
而像'en'这样的文件夹中
index.php
的内容是:echo "response in en folder
我利用@ Joe Raio的答案进行了一些修改:"; var_dump($_GET);
当我访问像
http://{web_site_name}.azurewebsites.net/index_cz.php?a=a&b=b
这样的网址时,它会在网站上返回:response in cz folder array(2) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" }
如有任何疑虑,请随时告诉我 .