Very Simple Rewrite question regarding subdirectory

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Very Simple Rewrite question regarding subdirectory

12 Nov 2013, 14:36

Hi,

I want to eliminate an old subdirectory "store" from URLs

Here's what I need to do:
OLD URL Example: http://mysite.com/store/Cat-Page-C25.aspx

New URL Example: http://mysite.com/Cat-Page-C25.aspx

Here is the code I am using:

RewriteCond %{HTTPS} (on)?
RewriteRule ^store/(.+) http(?%1s)://mysite.com/$1 [NC,R=301,L]

Here is the issue:

Instead of going to http://mysite.com/Cat-Page-C25.aspx
It is going to: http://mysite.com/category.aspx?categoryid=25

It is the correct page but I want the URL to display as:
http://mysite.com/Cat-Page-C25.aspx

Please help.

Thanks,

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

Re: Very Simple Rewrite question regarding subdirectory

12 Nov 2013, 17:28

Are there any other rules that you use in the config file? However, even this one (assuming querystring parameter comes from this rule) can be edited:

Code: Select all
RewriteCond %{HTTPS} (on)?
RewriteRule ^store/(.+) http(?%1s)://mysite.com/$1? [NC,R=301,L]


The small '?' at the end of the landing URL should cut off automatically appended querystring.

Regards
Andrew

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Very Simple Rewrite question regarding subdirectory

15 Nov 2013, 11:43

I added the ? after the $1 but this ends up with a 404 not found.

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Very Simple Rewrite question regarding subdirectory

15 Nov 2013, 11:44

And yes this is the only rule I have set.

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

Re: Very Simple Rewrite question regarding subdirectory

15 Nov 2013, 21:46

Does the redirect occur? Does the URL change?
We probably now need to set up a second rule to load content from original URL.

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Very Simple Rewrite question regarding subdirectory

18 Nov 2013, 12:20

No the redirection does not occur when I added the ? that you suggested. Nor does the URL change.

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

Re: Very Simple Rewrite question regarding subdirectory

18 Nov 2013, 12:43

We need the rewrite.log. This is strange.
Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html

Regards
Andrew

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Very Simple Rewrite question regarding subdirectory

18 Nov 2013, 13:44

Here is the log:

init rewrite engine with requested uri /store/category.aspx?categoryid=23
Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Htaccess process request c:\inetpub\wwwroot\mywebsite\.htaccess
applying pattern '^store/(.+)' to uri 'store/category.aspx'
RewriteCond: input='off' pattern='(on)?' => matched
escaping http://mysite.com/category.aspx
explicitly forcing redirect with http://mysite.com/category.aspx
internal redirect with /store/category.aspx?categoryid=23 [INTERNAL REDIRECT]

init rewrite engine with requested uri /category.aspx
Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Htaccess process request c:\inetpub\wwwroot\mywebsite\.htaccess
applying pattern '^store/(.+)' to uri 'category.aspx'
init rewrite engine with requested uri /Errors/PageNotFound.aspx
Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Htaccess process request c:\inetpub\wwwroot\mywebsite\.htaccess
applying pattern '^store/(.+)' to uri 'Errors/PageNotFound.aspx'


The requested URI is coming through as /store/category.aspx?categoryid=23
Even though I typed /store/pageexample-C23.aspx

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

Re: Very Simple Rewrite question regarding subdirectory

18 Nov 2013, 16:02

This means ISAPI_Rewrite is not the first to process the request. Do you have PLESK or CF installed?
What other ISAPI filters do you have in IIS?

Regards
Andrew

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Very Simple Rewrite question regarding subdirectory

19 Nov 2013, 14:45

Hi Andrew,

There are no other Rewrite programs other than the Application itself- Ablecommerce. Perhaps there is code handling the URL before it reaches Helicon ISAPI, even though I had Helicon ISAPI at the top of the chain in IIS for ISAPI filters. I ended up installiing the IIS rewrite module and was able to accomplish this with the following code:

<rewrite>
<rules>
<rule name="RemoveStore" stopProcessing="true">
<match url="^store$|^store/(.*)$" />
<conditions>
</conditions>
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="RewriteToFile" enabled="true">
<match url="^(?!store/)(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="store/{R:1}" />
</rule>
</rules>
</rewrite>

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 9 guests