我如何可以重写下面的例子?
How can I rewrite the examples below?
www.domain-name.com/site-name/index.php?lang=en-us&page=home www.domain-name.com/site-name/index.php?lang=en-us&page=about www.domain-name.com/site-name/index.php?lang=pt-pt&page=inicio www.domain-name.com/site-name/index.php?lang=pt-pt&page=sobre
www.domain-name.com/site-name/index.php?lang=en-us&page=home www.domain-name.com/site-name/index.php?lang=en-us&page=about www.domain-name.com/site-name/index.php?lang=pt-pt&page=inicio www.domain-name.com/site-name/index.php?lang=pt-pt&page=sobre
要这样:
www.domain-name.com/site-name/en-us/home.html www.domain-name.com/site-name/en-us/about.html www.domain-name.com/site-name/pt-pt/inicio.html www.domain-name.com/site-name/pt-pt/sobre.html
www.domain-name.com/site-name/en-us/home.html www.domain-name.com/site-name/en-us/about.html www.domain-name.com/site-name/pt-pt/inicio.html www.domain-name.com/site-name/pt-pt/sobre.html
我设法获得的页的参数。这是我有:
I managed to get the page parameter. This is what I have:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /site-name/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)/?$ index.php?page=$1 [L]
</IfModule>
我不知道该怎么追加的.html到底为人人的页的参数和正则表达式是真的不关我的事,所以有一些很难搞清楚林怎么了 - 一部分为郎的参数将起作用。我注意到,网站会很奇怪,当不正确的URL的类型。
I don't know how to append .html in the end for all "page" parameters and regex are really not my thing, so Im having some hard time figuring out how the "-" part for the "lang" parameter will work. I've noticed that website gets weird when incorrect url's are typed.
以后就会有它自己的域名,但我想更改的RewriteBase /网站名称/ 为的RewriteBase / 将修复它,对吗?
Later it will have it's own domain name, but I guess changing from "RewriteBase /site-name/" to "RewriteBase /" will fix it, right?
我不很了解,但我认为一些标志缺失太(搜索引擎优化的目的)。
I don't know much about it, but I think some flags are missing too (for SEO purposes).
您可以使用:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /site-name/
RewriteRule ^([^/]+)/(.+?).html?$ index.php?lang=$1&page=$2 [NC,L,QSA]
</IfModule>