is it possible to invert the url

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 14 Jan 2013, 18:49

is it possible to invert the url

15 Jan 2013, 10:59

I have the querystring with parameters working fine with this rewrite rule;

^([0-9,a-z,A-Z,_,-]+)\.asp$ http://myDomain.com/document/view.asp?ae=$1 [NC,R=301,L]

which rewrites for example to;

myDomain/EZas123.asp but can I turn around so that I have?,

EZas123.asp.myDomain (or something similar) and 2nd question, can I write this without the .asp extension?

EZas123.myDomain (this is my final objective)

Thanks

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: is it possible to invert the url

15 Jan 2013, 11:08

Would you, please, clarify what is the request you want to type on the browser and what landing URL do you want to have?

Regards
Andrew

User avatar
Posts: 3
Joined: 14 Jan 2013, 18:49

Re: is it possible to invert the url

15 Jan 2013, 12:34

Thanks for the quick reply

typed in the browser would be...

EZas123.myDomain.com

this would then redirect to...

http://myDomain.com/document/view.asp?ae=EZas123

I's like a subdomain but has to be dynamic generated, that's why I'm looking for a rewrite rule.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: is it possible to invert the url

15 Jan 2013, 21:30

ok, lets try:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} !^www\.myDomain\.com$
RewriteCond %{HTTP:Host} ^(.+)\.myDomain\.com$
RewriteRule ^$ http://myDomain.com/document/view.asp?ae=%1 [NC,L]


In case you want it to be a proxy request, please, add [P] in the flag section. In this case EZas123.myDomain.com will stay in the browser.

Regards
Andrew

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: is it possible to invert the url

16 Jan 2013, 10:51

I'm not sure that what's wanted is actually possible:

If you type EZas123.myDomain.com, surely that would need there to be an A or CNAME record for "EZas123.myDomain.com" pointing to the server?

Or does this rely on wildcarding? If so- what do you put in the <VirtualHost> tags to match anything? Can you put *.MyDomain.Com?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: is it possible to invert the url

16 Jan 2013, 11:16

It is possible, we've done it before. No manipulations with A or CName is needed. However, we've never tried <VirtualHost> for that. Usually just put it in .htaccess as workaround.

Regards
Andrew

User avatar
Posts: 3
Joined: 14 Jan 2013, 18:49

Re: is it possible to invert the url

16 Jan 2013, 15:57

That is slicker than a greased pig on downhill skis!

It works perfectly!

btw, does this present any additional security issues to be aware of.

Thanks for your help!

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: is it possible to invert the url

17 Jan 2013, 01:26

I don't know. Can it? We can narrow it down a little... by amount of symbols. But i'm not sure it's necessary.

regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 54 guests