AMH 社区首页
AMH社区 - 开放自由有价值的社区
[求助帖] 如何将不带www的网址全部301跳转? |
|
---|---|
joosan |
joosan 发表于 2015-03-02 12:00:48
本帖最后由 joosan 于 2015-3-2 13:31 编辑
请问高手,如何将我的网站不带www的,如aaa.com跳转到www.aaa.com;aaa.com/hitml全部跳转到www.aaa.com/hitml 在哪里改 这里?/usr/local/nginx/conf/nginx.conf 还是这里?/usr/local/nginx/conf/vhost/
点赞,加油! (0分)
2015-03-02 12:00:48 1
|
cs123456 |
在vhost里面的配置上修改
或者你条用个伪静态的规则,在规则内修改。
回复
2015-03-02 16:04:45 2
|
cs123456 |
if ($host = 'xxx.com' ) {
rewrite ^/(.*)$ http://www.xxx.com/$1 permanent; }
回复
2015-03-02 16:05:35 3
|
joosan |
本帖最后由 joosan 于 2015-3-2 17:25 编辑
终于有人回复了,先谢谢! 以下是dz的伪静态,应该怎么改?加在那个位置?在vhost里面我也不知道加在那个位置?有劳了! location / { rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last; if (!-e $request_filename) { return 404; } }
回复
2015-03-02 17:24:18 4
|
cs123456 |
放到主机conf文件里面
比如xxx.conf
回复
2015-03-02 17:57:19 5
|
joosan |
具体插入到那个地方? server { listen 80; server_name baidu.com www.baidu.com; #server_name end index index.html index.htm index.php; #index end set $subdomain ''; root /home/wwwroot/baidu/web$subdomain; include rewrite/discuz.conf; #rewrite end #error_page location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$ { root /home/wwwroot/baidu/web; } location ~ .*\.php$ { fastcgi_pass unix:/tmp/php-cgi-baidu.sock; fastcgi_index index.php; include fcgi-host.conf; fastcgi_param DOCUMENT_ROOT /home/wwwroot/baidu/web$subdomain; fastcgi_param SCRIPT_FILENAME /home/wwwroot/baidu/web$subdomain$fastcgi_script_name; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$ { expires 30d; } location ~ .*\.(js|css)$ { expires 12h; } access_log off; #access_log end error_log /dev/null; #error_log end }
回复
2015-03-02 18:57:57 6
|
amysql |
加在你已经有的规则上面就行了。
回复
2015-03-03 14:38:42 7
AMH面板 - 好用高效低占用、安全可靠极稳定 |
joosan |
老大 插入到伪静态规则前面出错了 [警告] Nginx配置Rewrite规则错误,请查检改正。 [AMRewrite-1.0 admin] [OK] AMRewrite-1.0 is already installed. nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /usr/local/nginx/conf/nginx.conf:84 nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
回复
2015-03-04 09:00:27 8
|