想了解create-react-app:如何使用https而非http?的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于createreactapptypescript的相关问题,此外,我们
想了解create-react-app:如何使用https而非http?的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于create react app typescript的相关问题,此外,我们还将为您介绍关于Angular 2 – 始终重定向到https://而不是使用http://、Apache – mod_rewrite – redirect一些pathHTTPS到HTTP、c# – 如何使用IHttpActionResult对Created-201响应进行编码、htaccess将http://和http:// wwwredirect到https://可以很好地与子域配合使用的新知识。
本文目录一览:- create-react-app:如何使用https而非http?(create react app typescript)
- Angular 2 – 始终重定向到https://而不是使用http://
- Apache – mod_rewrite – redirect一些pathHTTPS到HTTP
- c# – 如何使用IHttpActionResult对Created-201响应进行编码
- htaccess将http://和http:// wwwredirect到https://可以很好地与子域配合使用
create-react-app:如何使用https而非http?(create react app typescript)
我想知道是否有人知道如何在“ create-react-
app”环境中在dev上使用https。在README或快速谷歌搜索中我什么都看不到。我只希望https://
localhost:3000或https://
localhost:3001工作。
答案1
小编典典HTTPS=true
在运行启动命令之前进行设置。
文献资料
该实现使用HTTPS环境变量来确定启动服务器时要使用的协议。
Angular 2 – 始终重定向到https://而不是使用http://
重定向使用http的地址以使用https的最佳方法是什么?
现在,所有地址都重定向到https版本.
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="Redirect to https" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Apache – mod_rewrite – redirect一些pathHTTPS到HTTP
我的公司希望我们的网站强制大部分网站的http协议,除了“用户”,“商店”和“购物车”三个部分。 我使用http://htaccess.madewithlove.be/上的在线.htaccesstesting程序来构build我的文件,在那里似乎是正确的。 但是,当我实际执行它,我有一个问题。 如果我去https的任何常规网页的作品,我redirect到http版本就好了。 但是,如果我去'/ shop','/ cart',或'/ user',不pipe是用http还是https,我只是用httpredirect到主页。 这是.htaccess文件:
RewriteEngion on # Force HTTPS for /shop RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} /shop RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L] # Force HTTPS for /cart RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} /cart RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,L] # Force HTTPS for /user RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} /user RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,L] # Force HTTP for all others RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !/cart [NC] RewriteCond %{REQUEST_URI} !/shop [NC] RewriteCond %{REQUEST_URI} !/user [NC] RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [NC,L] # Pass all requests not referring directly to files in the filesystem to # index.PHP. Clean URLs are handled in drupal_environment_initialize(). RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.PHP [L]
从https转换到http时,RewriteRule违反
在Nginx,htaccess上韭菜
如何在PHP中显示Apache的默认404页面
该页面没有正确redirect – HTTPS HTACCESS重写错误
需要在.htaccess重写规则中转义#(哈希/磅)字符
您需要在您的条件下使用THE_REQUEST变量。 THE_REQUEST变量表示Apache从浏览器接收到的原始请求,并且在执行某些重写规则后不会被覆盖。 这个变量的值是GET /index.PHP?id=123 HTTP/1.1
# Force HTTPS for cart,shop,user RewriteCond %{HTTPS} off RewriteCond %{THE_REQUEST} s/(cart|shop|user) [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L] # Force HTTP for all others RewriteCond %{HTTPS} on RewriteCond %{THE_REQUEST} !s/(cart|shop|user) [NC] RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [NE,L] # Pass all requests not referring directly to files in the filesystem to # index.PHP. Clean URLs are handled in drupal_environment_initialize(). RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.PHP [L]
c# – 如何使用IHttpActionResult对Created-201响应进行编码
IHttpActionResult只有这些选项
>好的
>列表项
> NotFound
>异常
>未经授权
> BadRequest
>冲突重定向
> InvalidModelState
我现在在做的是下面的代码,但是我想使用IHttpActionResult而不是HttpResponseMessage
public IHttpActionResult Post(TaskBase model) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created,model); response.Headers.Add("Id",model.Id.ToString()); return ResponseMessage(response); }
解决方法
样品:
[Route("")] public async Task<IHttpActionResult> PostView(Guid taskId,[FromBody]View view) { // ... Code here to save the view return Created(new Uri(Url.Link(ViewRouteName,new { taskId = taskId,id = view.Id })),view); }
htaccess将http://和http:// wwwredirect到https://可以很好地与子域配合使用
我正在尝试redirect以下条件:
http://mydomain.com http://www.mydomain.com
至:
https://mydomain.com
但是我不希望它搞乱任何与子域名有关的事情,所以有人input:
http://m.mydomain.com
Apache目录closures – 站点中断
Apache友好的url
将Content-disposition标题仅设置到某个目录下的文件的附件中?
htaccess文件拒绝所有,redirect到404没有find403.shtml,但没有定义的自定义错误页面
使用htaccess以https支持添加www
不会被redirect到https。 我目前的htaccess文件如下所示:
# BEGIN wordpress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.PHP$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.PHP [L] </IfModule> # END wordpress
我试过使用一些我在这里发现的堆栈溢出的例子,比如这个:
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC,OR] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]
但是,虽然它似乎已经为那个人工作,它导致了我的“redirect循环”。 另外,我得到这个工作后,我需要添加一些redirect来处理子域,以不可见的方式(不改变URL)redirecthttp://m.mydomain.com到http://mydomain.com/m例如。 所以这里所做的一切都不应该阻止这种事情的发生。
如果有帮助,该网站托pipe在Rackspace云网站上
有人知道如何做到这一点?
谢谢!
编辑
我试过这个:
#http to https RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [L,R=301] #subdomain 1 RewriteBase / RewriteCond %{HTTP_HOST} ^sub1.mydomain.com [NC] RewriteRule ^(.*)$ http://mydomain.com/sub1/$1 [R=301,L]
它似乎工作的大部分,除了当我input一个子文件夹它似乎不工作。 例如,如果我在地址栏中input:
mydomain.com/temp
它解决了:
http://mydomain.com/temp/
编辑2
那么我已经取得了一些进展。 到目前为止,我有wwwredirect到非www和子域名工作(虽然地址栏确实改变 – 我想这是可以接受的)。 什么似乎搞乱了,如果我把任何forms的强迫https在那里。 它似乎与www到非www块相冲突。 我可以有一个或另一个。 有没有办法让这两个部分一起工作?
此外,wordpress的网站地址和wordpress地址都设置为https://mydomain.com
# BEGIN wordpress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.PHP$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.PHP [L] </IfModule> # END wordpress # Redirect from www to non-www location RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L] # Redirect http to https # THIS DOES NOT WORK - causes redirect loop #RewriteCond %{HTTPS} off #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} # subdomain RewriteBase / RewriteCond %{HTTP_HOST} ^sub1.mydomain.com [NC] RewriteRule ^(.*)$ http://mydomain.com/sub1/$1 [R=301,L] RewriteBase / RewriteCond %{HTTP_HOST} ^sub2.mydomain.com [NC] RewriteRule ^(.*)$ http://mydomain.com/sub2/$1 [R=301,L]
结论
对于大多数networking主机,anubhava的解决scheme将工作得很好。 然而,我相信这里的关键是Rackspace。 他们有自己喜欢的方法,我通过search他们的知识库find。 这是最好的htaccess文件。 所有wwwurl都被发送到非wwwurl,http被发送到https,子网域redirect到他们正确的子目录,而不会搞乱wordpress:
RewriteEngine On RewriteBase / #subdomain 1 RewriteCond %{HTTP_HOST} ^sub1.mydomain.com [NC] RewriteRule ^(.*)$ http://mydomain.com/sub1/$1 [R=301,L] #subdomain 2 RewriteCond %{HTTP_HOST} ^sub2.mydomain.com [NC] RewriteRule ^(.*)$ http://mydomain.com/sub2/$1 [R=301,L] #get rid of www,works with rackspace cloud sites RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L] #force https,works with rackspace cloud sites RewriteCond %{ENV:HTTPS} !on [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L] # BEGIN wordpress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.PHP$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.PHP [L] </IfModule> # END wordpress
非常感谢您的帮助。
哪个会是按国家redirect用户的最佳可扩展方式?
除了less数例外,将所有文件作为参数处理
如何在使用Apache重写时隐藏URL更改?
.htaccessredirect仅适用于部分url
Apache Rewrite:基于HTTP主机的映像目录
你可以有这样的.htaccess:
RewriteEngine On RewriteBase / #subdomain 1 RewriteCond %{HTTP_HOST} ^sub1.mydomain.com [NC] RewriteRule ^(.*)$ http://mydomain.com/sub1/$1 [R=301,L] # BEGIN wordpress <Ifmodulee mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.PHP$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.PHP [L] </Ifmodulee> # END wordpress
PS:请注意,HTTPS服务器变量在Rackspac云环境中未正确实施。 在Rackspace Cloud中查看HTTPS的正确变量是ENV:HTTPS 。
总结
以上是小编为你收集整理的htaccess将http://和http:// wwwredirect到https://可以很好地与子域配合使用全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
今天关于create-react-app:如何使用https而非http?和create react app typescript的分享就到这里,希望大家有所收获,若想了解更多关于Angular 2 – 始终重定向到https://而不是使用http://、Apache – mod_rewrite – redirect一些pathHTTPS到HTTP、c# – 如何使用IHttpActionResult对Created-201响应进行编码、htaccess将http://和http:// wwwredirect到https://可以很好地与子域配合使用等相关知识,可以在本站进行查询。
本文标签: