# Http-redirect not works

**URL:** https://forum.payara.fish/t/http-redirect-not-works/304
**Category:** Payara Server
**Created:** [April 21, 2022, 12:09pm UTC](https://forum.payara.fish/t/http-redirect-not-works/304 "2022-04-21T12:09:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gokhanersoy](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/gokhanersoy/32/121_2.png) [@gokhanersoy](https://forum.payara.fish/u/gokhanersoy)
#### Post date: [April 21, 2022, 12:09pm UTC](https://forum.payara.fish/t/http-redirect-not-works/304/1 "2022-04-21T12:09:12Z")

</div>

[http://unitag.asbu.edu.tr/](http://unitag.asbu.edu.tr/) --X–\> [https://unitag.asbu.edu.tr/](https://unitag.asbu.edu.tr/)

“http redirect to https” doesn’t work. please help me!

I’ve added following lines to default-web.xml

```auto
   <security-constraint>
		<web-resource-collection>
			<web-resource-name>Viewpoint Secure URLs</web-resource-name>
			<url-pattern>/*</url-pattern>
		</web-resource-collection>
		<user-data-constraint>
			<transport-guarantee>CONFIDENTIAL</transport-guarantee>
		</user-data-constraint>
	</security-constraint>

```

then, I have executed following commands.

```auto
asadmin create-protocol --securityenabled=false http-redirect

asadmin create-http-redirect --redirect-port 8181 --secure-redirect true http-redirect

asadmin create-protocol --securityenabled=false portunif-protocol

asadmin create-protocol-filter --protocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpRedirectFilter redirect-filter

asadmin create-protocol-finder --protocol portunif-protocol --targetprotocol http-listener-2 --classname org.glassfish.grizzly.config.portunif.HttpProtocolFinder http-finder

asadmin create-protocol-finder --protocol portunif-protocol --targetprotocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpProtocolFinder http-redirect

asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol=portunif-protocol

```

then following lines was added to domain.xml

```auto
          <protocol name="http-redirect">
            <http-redirect port="8181" secure="true"></http-redirect>
            <protocol-chain-instance-handler>
              <protocol-chain>
                <protocol-filter classname="org.glassfish.grizzly.config.portunif.HttpRedirectFilter" name="redirect-filter"></protocol-filter>
              </protocol-chain>
            </protocol-chain-instance-handler>
          </protocol>
          <protocol name="portunif-protocol">
            <port-unification>
              <protocol-finder protocol="http-listener-2" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-finder"></protocol-finder>
              <protocol-finder protocol="http-redirect" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-redirect"></protocol-finder>
            </port-unification>
          </protocol>
        </protocols>
        <network-listeners>
          <network-listener protocol="portunif-protocol" port="8585" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp"></network-listener>
          <network-listener protocol="http-listener-2" port="8181" name="http-listener-2" thread-pool="http-thread-pool" transport="tcp"></network-listener>
          <network-listener protocol="pu-protocol" port="4848" name="admin-listener" thread-pool="admin-thread-pool" transport="tcp"></network-listener>
        </network-listeners>

```

---

<div class="post-metadata">

### Author: ![JamesHillyard](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/jameshillyard/32/134_2.png) [@JamesHillyard](https://forum.payara.fish/u/JamesHillyard)
#### Post date: [June 29, 2022, 12:59pm UTC](https://forum.payara.fish/t/http-redirect-not-works/304/2 "2022-06-29T12:59:26Z")

</div>

Hi @gokhanersoy,

Using the latest version of Payara Community Edition, 5.2022.2, I was able to configure a simple servlet at localhost:8080/hello. I then added the snippet you gave to my web.xml file and ran the asadmin commands you listed. I made no manual changes to the domain.xml.

When I navigated to localhost:8080/hello again, I was redirected to localhost:8181/hello as expected. Does http redirect work as you expect if you make no manual changes to the domain.xml and use the latest version of Payara Community Edition?

Thanks,  
James
