1

I am working on a helicon rule and tried various combinations but they didn't work

I want the following URL to be resolved.

It can be this

www.test.com/myownpages/

or

www.test.com/myownpages
www.test.com/myownpages/?value1=test2&value2=test2

it should be resolved to

$1/test.aspx  [NC]

If anyone gives something after myownpages, it shouldn't work

www.test.com/myownpages/test (This shouldn't work)

It tried the below so far

RewriteRule ^(.*)(\/\myownpages\/)(.*)(\?)?(.+)?$ $1/test.aspx [NC] 
halfer
  • 19,824
  • 17
  • 99
  • 186
kobe
  • 15,671
  • 15
  • 64
  • 91

2 Answers2

1

I am not very familiar with these rewrite rules, but maybe I can help with the regex. As I read it, you want to match any string ending with "/myownpages", "/myownpages/", or "/myownpages/?anything" and capture the part before that. I'd use

^(.*)/myownpages(/([?].+)?)?$

to get this. See it in action at RegExr. If you need to escape the forward slashes, it becomes.

^(.*)\/myownpages(\/([?].+)?)?$

Note that this will not preserve the values in the query string; it will rewrite www.test.com/myownpages/?value1=test2&value2=test2 to www.test.com/test.aspx.

Jens
  • 25,229
  • 9
  • 75
  • 117
0

In case you want rewrite (NOT redirect) from /myownpages --> /myownpages/test.aspx, try using:

RewriteEngine on
RewriteBase /

RewriteRule myownpages/?$ /myownpages/test.aspx [NC,QSA,L]

QSA-flag appends the query string to the source path automatically.

Andrew
  • 511
  • 3
  • 7