This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
Common Questions (Forum Locked Forum Locked)
 Helicon Tech : Common Questions
Subject Topic: Rewrite folder to parameter (Topic Closed Topic Closed)
Author
Message |
pckiller
Newbie


Joined: 05 May 2009
Posts: 7
Posted: 05 May 2009 at 1:44am  


I have this url:

http://www.mysite.com/myfolder

and I need to rewrite in this format:

http://www.mysite.com/default.asp?myparameter=myfolder

Can anyone help me?

Tks...
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 05 May 2009 at 9:27am  

Please use the following config:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ default.asp?myparameter=$1 [NC,L]

__________________
Regards,
Anton
Back to Top
 
pckiller
Newbie


Joined: 05 May 2009
Posts: 7
Posted: 05 May 2009 at 2:02pm  

Anton,

the code you post didn't work. I'm using this code below:

Code:

[ISAPI_Rewrite]

#Redirect folder to a parameter
RewriteEngine on
RewriteRule ^/(.+)\/?([0-9]*)\/?$    /default.asp?id=$1


and it's working well
but lost the site format (css, images)

What is wrong?

Regards,
Eduardo

Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 06 May 2009 at 5:20am  

Could you please specify what version of ISAPI_Rewrite you are using.
And please consider using root-relative or absolute links for css/images.

__________________
Regards,
Anton
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 06 May 2009 at 5:26am  

Could you please specify what version of ISAPI_Rewrite you are using.
And please consider using root-relative or absolute links for css/images.

__________________
Regards,
Anton
Back to Top
 
pckiller
Newbie


Joined: 05 May 2009
Posts: 7
Posted: 06 May 2009 at 6:39pm  

Anton,

The version is 2.6 running in a Windows Server 2003.

I'm using document relative, but I change all paths for site relative but the problem continue...

Regards,
Eduardo
Back to Top
 
pckiller
Newbie


Joined: 05 May 2009
Posts: 7
Posted: 06 May 2009 at 6:42pm  

Anton,

One more information....

I test the page with absolute paths like http://www.mysite.com/images/image.jpg

But the same problem...

Regards,
Eduardo
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 07 May 2009 at 7:08am  

Please try to use the following config:

[ISAPI_Rewrite]

#Redirect folder to a parameter
RewriteRule /(?!.*\.(?:gif|jpg|png|css))(.+)/?([0-9]*)/?    /default.asp\?id=$1 [I,L]

__________________
Regards,
Anton
Back to Top
 
pckiller
Newbie


Joined: 05 May 2009
Posts: 7
Posted: 07 May 2009 at 10:19am  

Anton,

The images and css is ok now, but every file or forder I try to access and exist, the isapi_rewriter redirect for the default.asp as a parameter.

I need to use this rule only if the folder not exist.

I Would like:
The file exist = Don't use ISAPI_Rewriter
The file not exist = Show page not found (don't use ISAPI_Rewriter)
The folder exist = Don't use ISAPI_Rewriter
The folder not exist = Use ISAPI_Rewriter

Do you understand me?

I try this code :

Code:

[ISAPI_Rewrite]

#Redirect folder to a parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /(?!.*\.(?:gif|jpg|png|css))(.+)/?([0-9]*)/?    /default.asp\?id=$1 [I,L]


but the conditions didn't work...

Regards,
Eduardo


Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 08 May 2009 at 4:36am  

Unfortunately the conditions you tried above don't work in v2, so you need to exclude the existing folders like this:

[ISAPI_Rewrite]

#Redirect folder to a parameter
RewriteRule /(?!(?:.*\.(?:gif|jpg|png|css)|folder|folder2|etc))(.+)/?([0-9]*)/?    /default.asp\?id=$1 [I,L]

Consider excluding only top level folders and their children will also be excluded.

__________________
Regards,
Anton
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum