| Author |
|
pckiller Newbie

Joined: 05 May 2009
Online Status: Offline Posts: 7
|
| Posted: 05 May 2009 at 1:44am | IP Logged
|
|
|
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
Online Status: Offline Posts: 10520
|
| Posted: 05 May 2009 at 9:27am | IP Logged
|
|
|
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
Online Status: Offline Posts: 7
|
| Posted: 05 May 2009 at 2:02pm | IP Logged
|
|
|
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
Online Status: Offline Posts: 10520
|
| Posted: 06 May 2009 at 5:20am | IP Logged
|
|
|
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
Online Status: Offline Posts: 10520
|
| Posted: 06 May 2009 at 5:26am | IP Logged
|
|
|
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
Online Status: Offline Posts: 7
|
| Posted: 06 May 2009 at 6:39pm | IP Logged
|
|
|
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
Online Status: Offline Posts: 7
|
| Posted: 06 May 2009 at 6:42pm | IP Logged
|
|
|
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
Online Status: Offline Posts: 10520
|
| Posted: 07 May 2009 at 7:08am | IP Logged
|
|
|
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
Online Status: Offline Posts: 7
|
| Posted: 07 May 2009 at 10:19am | IP Logged
|
|
|
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
Online Status: Offline Posts: 10520
|
| Posted: 08 May 2009 at 4:36am | IP Logged
|
|
|
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 |
|
| |