【发布时间】:2016-05-30 22:29:50
【问题描述】:
我正在尝试重写我的 nginx 以使用 http://domain.com/main 而不是使用 http://domain.com/?page=main
我已经完成了:
try_files $uri $uri/ /index.php?page=$uri;
返回空白页
rewrite ^/(\w+)$ /index.php?page=$1 break;
rewrite ^/(\w+)+\/$ /index.php?page=$1 break;
if ($http_host !~ "^$"){
rewrite ^(.*)$ http%1://www.$http_host$request_uri redirect;
}
生成网址:http://domain.com/main/http://domain.com/main/http://domain.com/main
这是 Apache .htaccess:
RewriteEngine on
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA]
RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
【问题讨论】:
-
我可以使用凹凸吗?