Sunday, April 30, 2017

Relative form action removes 4th grade subdomain

Leave a Comment

I have issue with HTML form which is pointing its action to: /index.php?something=x

So its looks like

<form action="/index.php?something=x" method="POST"> 

I have production of application running on subdomain xx.example.com

When i submit form, everything works well, request is going to:

xx.example.com/index.php?something=x

But on development environment i have 4th grade url. Example: yy.xx.example.com

When i submit form on dev environment request is not going to https://yy.xx.example.com/index.php?something=x

but url is without yy => https://xx.example.com/index.php?something=x and it is wrong.

Any suggestions?

2 Answers

Answers 1

It's not problem in URL, you can have domain or sub domain as you like.
it can be, as you said 4th grade URL or longer "https://zz.yy.xx.example.com/".
Tested in my localhost xampp and on real server with some test sub domain.

Try to fix your code, you have two action fields

action="POST" 

Replace second "action" with "method". It should be like this:

<form action="/index.php?something=x" method="POST"> 

Answers 2

To check, what is happening with your site, I have created two subdomains on the domain http://techdeft.com namely http://xx.techdeft.com and http://yy.xx.techdeft.com.

Now when I created a simple form on these sub-domains and actions set to, what you have mentioned in the question, I found that everything works fine with these sub-domains. You can check here http://xx.techdeft.com and http://yy.xx.techdeft.com.

here, is the possible solution to your problem-

<form action="http://<?php echo $_SERVER['SERVER_NAME'];?>/index.php?something=x" method="POST"> 

Using this your problem must be solved. Do let me know, have it worked for you? Thanks

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment