• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 68
  • Last Modified:

Regex to test if homepage?

I need a regex that identifies only a homepage. For example https://www.mydomain.com or http://www.mydomain.com. if there is any path after this, it has to fail. Although http(s)://www.mydomain.com/ is acceptable.

Thanks
0
894359
Asked:
894359
  • 5
  • 4
  • 2
1 Solution
 
SSupremeCommented:
0
 
Dave BaldwinFixer of ProblemsCommented:
What about http://www.mydomain.com/index.html which is also the home page on many sites?
0
 
SSupremeCommented:
No, It isn't. Try http://www.experts-exchange.com/index.html
/ is a call of default website file and otherwise the list would continue
index.htm
index.shtml
index.php
index.php5
index.php4
index.php3
index.cgi
default.html
default.htm
home.html
home.htm
Index.html
Index.htm
Index.shtml
Index.php
Index.cgi
Default.html
Default.htm
Home.html
Home.htm
placeholder.html
....aspx
0
WEBINAR: 10 Easy Ways to Lose a Password

Join us on June 27th at 8 am PDT to learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees. We'll cover the importance of multi-factor authentication and how these solutions can better protect your business!

 
Dave BaldwinFixer of ProblemsCommented:
@SSupreme, you just made my point exactly.  Besides... I said 'many' sites, not all sites.
0
 
894359Author Commented:
Sorry... what if there is a query string?  http://www.mydomain.com/?a=b or  http://www.mydomain.com?a=b  Just thought about this!
0
 
SSupremeCommented:
What do you what to do? My regex doesn't allow it.
0
 
894359Author Commented:
But what is there is a query string? I don't care about things like "index.html" but I do care about query strings!
0
 
SSupremeCommented:
Do you what to allow query string?
0
 
894359Author Commented:
yes I do want to allow query strings.

Thank you!
0
 
SSupremeCommented:
0
 
894359Author Commented:
That worked! Thank you!  ^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/|\?.+\=.+)?(\?.+\=.+)?$
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

WEBINAR: 10 Easy Ways to Lose a Password

Join us on June 27th at 8 am PDT to learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees. We'll cover the importance of multi-factor authentication and how these solutions can better protect your business!

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now