Very Simple Rewrite question regarding subdirectory
10 posts
• Page 1 of 1
Very Simple Rewrite question regarding subdirectory
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,
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,
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Very Simple Rewrite question regarding subdirectory
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:
The small '?' at the end of the landing URL should cut off automatically appended querystring.
Regards
Andrew
- 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
Re: Very Simple Rewrite question regarding subdirectory
I added the ? after the $1 but this ends up with a 404 not found.
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Very Simple Rewrite question regarding subdirectory
Does the redirect occur? Does the URL change?
We probably now need to set up a second rule to load content from original URL.
We probably now need to set up a second rule to load content from original URL.
Re: Very Simple Rewrite question regarding subdirectory
No the redirection does not occur when I added the ? that you suggested. Nor does the URL change.
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Very Simple Rewrite question regarding subdirectory
We need the rewrite.log. This is strange.
Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html
Regards
Andrew
Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html
Regards
Andrew
Re: Very Simple Rewrite question regarding subdirectory
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
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
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Very Simple Rewrite question regarding subdirectory
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
What other ISAPI filters do you have in IIS?
Regards
Andrew
Re: Very Simple Rewrite question regarding subdirectory
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>
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>
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests