我的目标是重写http://localhost:8000下的所有内容到http://localhost/foo 我遵循这个链接中提到的每一个步骤,但仍然无法得到它的工作。 这是我的设置: urls.py(Django) urlpatterns = [ url(r'^$', 'home.view'), url(r'^foo$', 'foo.view'), ] uwsgi.ini(uWSGI) [uwsgi] chdir = /home/user/folder/project wsgi-file = /home/user/folder/project/iTrends/wsgi.py home = /home/user/.pyenv/versions/project master = true processes = 10 threads = 5 socket = /tmp/project.sock chmod-socket = 666 vacuum = true logto = /tmp/project_uwsgi.log http-websocket = true buffer-size = 65535 nginx80.conf(带端口80的nginx) server { listen 80; […]
这与几年前我问过的一个老问题有关 ,对此我从来没有得到正确的答案。 我只是build立一个新的服务器(Ubuntu 16.04,Nginx 1.10,PHP 7),并回到这个。 我有一个Question2Answer实例运行在一个子文件夹中,其他PHP代码从根目录运行。 对于根的东西,我有这在我的服务器块: location / { try_files $uri $uri/ /index.php?$request_uri; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } 对Q2A来说,我在旧服务器上所拥有的是: location /qa/ { if (!-e $request_filename) { rewrite ^/qa/(.*)$ /qa/index.php?qa-rewrite=$1 last; } } 这是行得通的,但我不认为这是应该如何做(如果是邪恶等)。 我确定只能使用try_files 。 我试过这个: location /qa/ { try_files $uri $uri/ /qa/index.php?qa-rewrite=$uri&$args; } 但是它不起作用,因为/qa/在qa-rewrite传递。 它应该只是通过path后的一切。 有没有办法从$urivariables中删除/qa/ ? […]
我有一个在核心PHP开发的静态网站(没有框架使用),我也安装了一个博客使用wordpress在同一个域下的子目录。 Like : example.com/blog 由于主站点是使用静态php文件构build的,因此按照SEO推荐,我写了一个简单的重写规则来从URL删除.php扩展名。 所以 http://example.com/abc.php will rewrite to http://example.com/abc 现在到了实际的问题。 当我尝试login到http://example.com/blog/wp-admin并把用户名和密码redirectwp-login.php,但由于上述重写规则它更改为wplogin,并导致找不到redirect404页面在主要站点。 重写规则Nginx的vhost-conf是: location ~ \.php$ { if ($request_uri ~ (.*)\.php$) { return 301 $1; } try_files $uri =404; expires off; fastcgi_read_timeout 900s; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9001; 我知道这可能不是最好的方法,但我已经尝试了几乎几个小时stackexchange几乎所有的答案,最后得到这个使用上面的工作。 我的问题是,如何从这种redirect排除wp-admin? 否则有人可以build议任何替代良好的redirect/重写规则,以避免这种冲突? 完整的Nginxconfiguration: server { listen 80; # Default listen port if ($host = […]
我在这里有问题。 我已经从apt上安装了nginx,所以它有nginx -V的以下输出: nginx version: nginx/1.6.2 TLS SNI support enabled configure arguments: –with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-se curity -D_FORTIFY_SOURCE=2' –with-ld-opt=-Wl,-z,relro –prefix=/usr/share/nginx –conf-path=/ etc/nginx/nginx.conf –http-log-path=/var/log/nginx/access.log –error-log-path=/var/log/nginx /error.log –lock-path=/var/lock/nginx.lock –pid-path=/run/nginx.pid –http-client-body-temp- path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-proxy-temp-pat h=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/l ib/nginx/uwsgi –with-debug –with-pcre-jit –with-ipv6 –with-http_ssl_module –with-http_stu b_status_module –with-http_realip_module –with-http_auth_request_module –with-http_addition _module –with-http_dav_module –with-http_geoip_module –with-http_gzip_static_module –with- http_image_filter_module –with-http_spdy_module –with-http_sub_module –with-http_xslt_modul e […]
我怎样才能做一个重写规则http://example.com/abc重写/redirect到http://example.com/abc.html但它应该工作时,我的URL为http://example.com/abc/def.html 。 目前,当我redirect 301 "abc" "abc.hml" ,第二个URL也redirect到http://example.com/abc.html/def.html 。 我目前的规则。 <IfModule rewrite_module> RewriteEngine On RewriteRule ^/$ /content/aaa-123/abc.html [PT,L] RewriteRule ^/index.html$ /content/aaa-123/abc.html [PT,L] RedirectMatch ^/abc$ /abc.html RewriteCond %{REQUEST_URI} !^/(.*)/$ RewriteCond %{REQUEST_URI} !^(.*)\.(.*)$ RewriteRule ^/(.*)$ /content/$1/ [L] RewriteRule \.(css|jpe?g|gif|png|js)$ – [L] ErrorDocument 404 /errors/404.html <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" […]
如何使用IIS7.5远程pipe理我们的网站,将一个子域名redirect到一个文件夹? 所以: sub.MyDomain.com将parsing为MyDomain.com/folder 我试过使用URL重写,但它似乎没有任何效果。 我没有看到任何有关DNS传播的信息(似乎没有必要)。 我是否需要以某种方式设置DNSlogging知道IIS正在处理该子域? 仅供参考,这里是我使用的设置: 如果模式是为我创build的CNAME DNSlogging(指向主域:www.BungalowSoftware.com)的子域,那么我得到一个403禁止的结果(所以它打到服务器@ web.com)如果子域名不存在于DNS(CNAME),那么我得到“未find”。
我将redirect我的域到特定的path。 我想要的是 admin.example.com to admin.example.com/admin partner.example.com to partner.example.com/partner 我需要在一个.htaccess文件中的这两个function。 谢谢。
我有以下urlwww.example.com/advice/现在注意在URL的末尾的斜线? 我希望将其移除为www.example.com/advice 。 现在,当我在浏览器中input该URL时,我将redirect到带有斜线的尾部,即使以curl为例。 现在我知道后面的斜杠正在增加,因为通知是一个实际的目录。 [steve@dev dev.www.example.com]$ curl -I https://dev.www.example.com/advice -k HTTP/1.1 301 Moved Permanently Date: Fri, 25 Nov 2016 08:20:11 GMT Server: Apache/2.4.6 (CentOS) Location: https://dev.www.example.com/advice/ Cache-Control: max-age=0 Expires: Fri, 25 Nov 2016 08:20:11 GMT Connection: close Content-Type: text/html; charset=iso-8859-1 [steve@dev dev.www.example.com]$ curl -I https://dev.www.example.com/advice/ -k HTTP/1.1 200 OK Date: Fri, 25 Nov 2016 […]
我需要使用nginx重写来重写旧的url。 查询string有一个问题。 如果旧url具有查询string参数,redirect不起作用。 我目前的configuration: map $request_uri $newuri { /old-url/path /new-url/path; } server { location / { if ($newuri) { return 301 $newuri; } } }
运行WP多站点,客户端可以使用自己的域名。 很好的工作 – 除了客户端不使用我的名称服务器,只是有一个指向WP静态IP地址的Alogging的情况。 当客户端DNS有大量服务logging(例如Office 365)时,有时会发生这种情况,将DNS留在那里更安全。 当我控制DNS时,我可以将非WWW别名到WWW,这使WP多站点感到高兴。 当客户端刚刚使用Alogging指针时,WP多站点在传入的非WWW请求中跳转,并落在多站点的注册页面上。 它真的需要'万维网',工作正确(不幸)。 我通过在.htaccess中这样做解决每个客户: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteRule ^(.*) http://www.example.com/$1 [L,R=301] </IfModule> 迄今为止似乎工作很好。 问题: 这个方法看起来是否合理? 鉴于我所看到的问题,有没有更好的方法来处理这个问题? 如果我想使这个重写通用来处理任何传入域(只要该域不包括我的基地多站点域名!) – 有人可以告诉我如何形成条件/规则? 我喜欢硬编码的实际领域,因为这保证没有别的被触动,但我会想象一旦我有几百这些可能会变得愚蠢。