我想要实现的目标:
http://example.com/en - > http://example.com/?lang=en
http://example.com/en/something - > http://example.com/something/?lang=en
http://example.com/ru - > http://example.com/?lang=ru
http://example.com/ru/something - > http://example.com/something/?lang=ru
我尝试:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/(.+)$ /?p=$1&lang=en [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ru/(.+)$ /?p=$1&lang=ru [L,QSA]
答案 0 :(得分:1)
你可以这样做:
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Ember-Charts Starter Kit" />
<meta charset="utf-8">
<title>Ember Charts Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<!-- Ember and dependencies -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.js"></script>
<script src="http://builds.emberjs.com/tags/v1.4.0/ember.js"></script>
<!-- Ember Charts and dependencies -->
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.10/d3.min.js"></script>
</head>
<body>
<script type="text/x-handlebars">
<h2> Welcome to Ember Charts!</h2>
<p>Version 0.3.0</p>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<div class="col-md-3">
<h3>Choisir le Groupe</h3>
<div class="selectPicker">
<select id="graphselection" name="dataset" action="change-dataset">
<option value="all">All</option>
{{#each dataset in model}}
<option value="{{dataset}}">{{dataset}}</option>
{{/each}}
</select>
</div>
</div>
<div class="col-md-9">
{{visu-chart dataset=agro elementId="scatter-load"}}
</div>
</script>
<script type="text/x-handlebars" id="components/visu-chart">
<div class="visu-chart"></div>
</script>
</body>
</html>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(ru|en)/(.+)$ /$2/?lang=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(ru|en)/?$ /?lang=$1 [L,QSA]
将匹配(ru|en)
或ru
。如果您想将其设为通用2字母匹配,则可以使用en