GVKun编程网logo

将htaccess转换为nginx重写(nginx换成apache)

24

本篇文章给大家谈谈将htaccess转换为nginx重写,以及nginx换成apache的知识点,同时本文还将给你拓展.htacces-SetEnvIf转换为NGinx-fastcgi_param、.

本篇文章给大家谈谈将htaccess转换为nginx重写,以及nginx换成apache的知识点,同时本文还将给你拓展.htacces-SetEnvIf转换为NGinx-fastcgi_param、.htaccess – nginx中MEAN-stack应用程序的漂亮url、.htaccess转httpd.ini 求高手帮忙、.htaccess重写规则强制将httpsredirect到http等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

将htaccess转换为nginx重写(nginx换成apache)

将htaccess转换为nginx重写(nginx换成apache)

.htaccess的Nginx重写转换帮助

RewriteEngine On RewriteBase / RewriteRule ^c-(.*)$ catpost.PHP?id=$1 [L] RewriteRule ^a-(.*)-(.*)$ archives.PHP?month=$1&year=$2 [L] RewriteCond %{REQUEST_FILENAME} !-d [NC] RewriteCond %{REQUEST_FILENAME} !-f [NC] RewriteRule ^(.*)$ viewpost.PHP?id=$1 [QSA,L]

将HTTPredirect到HTTPS和WWW到非WWW URL

在重写.htaccess中保留查询string

Codeigniter Htaccess和URLredirect问题

.htaccess – 重写查询string并redirect到目录

.htaccess使用UTF 8字符redirectURL

假设你有一个可行的PHP实现,请尝试:

location / { rewrite ^/c-(.*)$ /catpost.PHP?id=$1 last; rewrite ^/a-(.*)-(.*)$ /archives.PHP?month=$1&year=$2 last; try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/(.*)$ /viewpost.PHP?id=$1 last; }

要记住的主要事情是Nginx URI以前导/开头。

头两个重写可能在location块内或不在 – 取决于你有什么其他的location块。 详情请参阅此文件 。

条件重写基本上是try_files设计的目的。 我们使用一个命名的位置来丢失前导/ 。 详情请参阅此文件 。

.htacces-SetEnvIf转换为NGinx-fastcgi_param

.htacces-SetEnvIf转换为NGinx-fastcgi_param

我有以下.htaccess设置以及我的Apache网站; 现在我正在把它移到Nginx。 因此,我不知道如何才能把.htaccess文件中的“SetEnvIf”参数放在Nginxconfiguration文件中? 我想通过设置''fastcgi_param'',请帮我做转换。

SetEnvIf HOST albany.mywebsite.com MAGE_RUN_CODE=w2760 SetEnvIf HOST albany.mywebsite.com MAGE_RUN_TYPE=website SetEnvIf HOST alexandria.mywebsite.com MAGE_RUN_CODE=w1472 SetEnvIf HOST alexandria.mywebsite.com MAGE_RUN_TYPE=website SetEnvIf HOST annarbor.mywebsite.com MAGE_RUN_CODE=w2933 SetEnvIf HOST annarbor.mywebsite.com MAGE_RUN_TYPE=website

谢谢。

将一个URLredirect到另一个URL – 删除查询string

Nginx.conf用于restful api

Apache .htaccess <目录不允许在这里

请求的资源.htaccess上不存在Access-Control-Allow-Origin标头

使用.htaccess将一个特定的IP地址redirect到我的主页的特殊页面

你可以这样做:

if ($host = albany.mywebsite.com) { env MAGE_RUN_CODE=w2769; env $MAGE_RUN_TYPE=website; }

(对于其他主机值等等)

请参阅http://Nginx.org/en/docs/ngx_core_module.html#env

总结

以上是小编为你收集整理的.htacces-SetEnvIf转换为NGinx-fastcgi_param全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

.htaccess – nginx中MEAN-stack应用程序的漂亮url

.htaccess – nginx中MEAN-stack应用程序的漂亮url

(*正如一些评论建议,我删除了index.ejs并在项目中使用index.html遵循this answer.所以我调整了我的OP *)

我在Mac上用apache开发了一个可以请求的MEAN-stack应用程序
https://开头本地主机:3000 /#/家.在使用Nginx服务器进行生产时,可以请求应用程序
 https://www.myapp.io/#/home.由于角度ui-router,在所有情况下都需要片段标识符#.

所以我想在没有#(例如,https://www.myapp.io/home,https:// localhost:3000 / home)的情况下制作漂亮的网址.我做了以下事情:

1)添加$locationProvider.html5Mode(true); app.config中的$locationProvider.hashPrefix(”)([‘$stateProvider’….

2)添加< base href =“/”/>在index.html中

因此,https:// localhost:3000 /#/ home会自动更改为浏览器栏中的https:// localhost:3000 / home,类似于https://www.myapp.io/#/home.

但是,在浏览器中直接输入https:// localhost:3000 / home或https://www.myapp.io/home会引发错误(我不知道如何转换前一个< h1><%=消息%>< / h1>< h2><%= error.status%>< / h2>< pre><%= error.stack%>< / pre>错误. ejs到error.html,所以我没有更多细节).

所以现在,目标是使https:// localhost:3000 / home和https://www.myapp.io/home工作.

按照this thread,我在app.js中添加了以下内容:

app.use('/js',express.static(__dirname + '/js'));
app.use('/dist',express.static(__dirname + '/../dist'));
app.use('/css',express.static(__dirname + '/css'));
app.use('/partials',express.static(__dirname + '/partials'));    
app.all('/*',function(req,res,next) {
    res.sendFile('index.html',{ root: __dirname });
});

在mac的apache中,这是我的httpd-vhosts.conf,重启apache之后,
https:// localhost:3000 / home仍然返回错误.

在生产中,这是Nginx服务器块.重新启动Nginx后,https://www.myapp.io/home仍然会返回错误.

server {
    listen 443 ssl;

    server_name myapp.io www.myapp.io;

    ssl_certificate /etc/letsencrypt/live/myapp.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/myapp.io/privkey.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:EC$
    ssl_session_timeout 1d;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;

    index index.html;

    root /opt/myapp

    location / {
        try_files $uri $uri/ /index.html;
    }

    location ~ /.well-kNown {
        allow all;
    }

    location / {
        proxy_set_header    Host                $host;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   $scheme;
        proxy_set_header    Accept-Encoding     "";
        proxy_set_header    Proxy               "";
        proxy_pass          https://127.0.0.1:3000;

        # These three lines added as per https://github.com/socketio/socket.io/issues/1942 to remove sock$

        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
}

有人可以帮忙吗?

最佳答案
我认为你应该问自己更好的问题是为什么你没有index.html?也许我已经睡了太久了,但是浏览器实际上不能在网页上自己执行JavaScript,没有来自HTML文档的底层DOM.

一旦你理解了这一点,你可能会成功获得GitHub上angular-ui的官方配置建议.

.htaccess转httpd.ini 求高手帮忙

.htaccess转httpd.ini 求高手帮忙

RewriteEngine on
RewriteRule ^([0-9a-zA-Z_]+)/([0-9]+).html index.php?mod=$1&act=$2
RewriteRule ^([0-9]+)-(.*) index.php?mod=package&act=$1&u=$2
RewriteRule ^notice/list/([0-9]+)_([0-9]+).html index.php?mod=notice&act=list&class=$1&page=$2
RewriteRule ^notice/([0-9]+)_([0-9]+).html index.php?mod=notice&act=$1&page=$2
RewriteRule ^faq/list/([0-9]+).html index.php?mod=faq&act=list&page=$1
RewriteRule ^comment/([0-9a-zA-Z_]+)/([0-9]+).html index.php?mod=comment&act=$1&id=$2
RewriteCond %{HTTP_HOST} ^baidu.com$
RewriteRule ^/?$ "http\:\/\/www\.baidu\.com\/" [R=301,L]

.htaccess重写规则强制将httpsredirect到http

.htaccess重写规则强制将httpsredirect到http

我有一个主域名https://www.domain.com或https://domain.com和像https://domain.com/index.PHP?name=abcd强制通过http://abcd.domain.comredirect的通配DNS http://abcd.domain.com但我有另一个问题,我的login页面是https://domain.com/login.PHP?name=abcd ,我想结果像强制http://domain.com/login.PHP?name=abcd但它不能在HTTP上redirect。

RewriteEngine On #match either the www subdomain or no subdomain RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ #which request index.PHP RewriteCond %{REQUEST_URI} ^/index.PHP #and contain a username paramater RewriteCond %{QUERY_STRING} ^(.*?)(?:^|&)name=([^&]+)(.*?)$ #then rewrite them to name.domain.com without the name parameter RewriteRule ^ http://%1.domain.com%{REQUEST_URI} [R,L] #match either the www subdomain or no subdomain RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ #which was requested without https RewriteCond %{HTTPS} off #then redirect to https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L] #Capture subdomain RewriteCond %{HTTP_HOST} ^([^.]+).(?:domain.com)$ #If we're not working on www RewriteCond %{HTTP_HOST} !^(?:www.domain.com)$ #If querystring doesn't contain name RewriteCond %{QUERY_STRING} !^(.*?)(?:^|&)name=([^&]+)(.*?)$ #Add username to querystring RewriteRule index.PHP index.PHP?name=%1 [L,QSA]

这个htaccess的代码工作正常,但我想login脚本在htaccess

在聊天澄清后,这是我所需要的:

所有的URL都应该被重写为https ,除了login.PHP ,它应该停留在http 。 如果login.PHP以https ,请将其重写为http 。

请求的资源.htaccess上不存在Access-Control-Allow-Origin标头

mod_rewrite不适用于Windows 7上的Apache 2.2

Apache .htaccess隐藏.PHP和.html扩展名

如何使mod_rewrite从子域redirect到查询string?

如果不是带有apache的目录,则删除结尾的斜杠

我怎样才能设置CORS访问我的Linux Web服务器上的audio文件与Apache2?

在htaccess中禁用PHP函数

多国使用.htacces

无法获取.htaccess mod_rewrite规则工作 – 404找不到

.htaccess:如果调用特定的目录,则重写整个URL

你已经有重写为https的规则,唯一剩下的就是不包括login.PHP

RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !^/login.PHP$ RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

如果用 https请求login.PHP ,则将其重写为http

RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ RewriteCond %{HTTPS} on RewriteRule ^login.PHP$ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

最后,一个小提示: 从不测试301启用,看到这个答案提示调试.htaccess重写规则的细节。

尝试这个 :

RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

今天关于将htaccess转换为nginx重写nginx换成apache的分享就到这里,希望大家有所收获,若想了解更多关于.htacces-SetEnvIf转换为NGinx-fastcgi_param、.htaccess – nginx中MEAN-stack应用程序的漂亮url、.htaccess转httpd.ini 求高手帮忙、.htaccess重写规则强制将httpsredirect到http等相关知识,可以在本站进行查询。

本文标签: