View previous topic :: View next topic |
Author |
Message |
thinkr -
Joined: 24 Oct 2013 Posts: 15 Location: California
|
Posted: Fri Nov 14, 2014 8:54 am Post subject: Can I filter a character out after matching? |
|
|
I have many urls like this...
http://domain.com/constantpath/seriesofcharacterswithslashes.html
...where I need to perform a 301 redirect to the new url where the slashes are removed from the backreference...
http://domain.com/constantpath/seriesofcharacterswithslashesremoved.html
The number of slashes could range from 0 to 5. I know how to match with the slashes in, but then how do I remove the slashes in the new URL?
I'm new to URL rewrite, figured out a lot of things and tested them, but the above scenario is one I haven't found a coding method for. Help would be appreciated. _________________ If you don't question it then you don't know it. |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Sun Nov 30, 2014 11:44 pm Post subject: |
|
|
Figured it out for you.
Virtual path regex:
Code: | ^/constant/([^\/]*)\/([^\.]*)(\..*)$ |
Conditions: SCRIPT_NAME Is not a file (applied to sub-requests too)
If rule matches, perform internal redirection.
Redirect to:
Append query string. Escape redirection location.
Next action: Restart from beginning
Scenario:
I have a folder under the root www dir named constant.
I have a file in the constant folder named a23413b2.htm
I'm trying to access this URL: http://domain.com/constant/a234/1/3/b/2.htm
Abyss strips away the slashes after /constant/ in the URL until there are no more slashes.
Thus, /constant/a234/1/3/b/2.htm --> /constant/a23413b2.htm
By the way, a great resource for learning regex is http://www.regular-expressions.info/tutorial.html. The Regex Coach is a great way to test out your own regex. It's free --> http://weitz.de/files/regex-coach.exe. I used both in helping you :) _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Wed Dec 03, 2014 4:26 pm Post subject: Re: Can I filter a character out after matching? |
|
|
thinkr wrote: | I need to perform a 301 redirect to the new url where the slashes are removed from the backreference... |
The solution I listed in the post above does not accomplish a 301 redirect.
pksml wrote: | Thus, /constant/a234/1/3/b/2.htm --> /constant/a23413b2.htm |
To further clarify what my solution does...
*The browser will request the URL with the slashes
*Abyss will do the URL rewriting processing
*Abyss will locate the real file you're wanting to serve and send it
Thus, the browser gets the file you're wanting them to get to, but their URL bar will still have the URL with the slashes.
If that's not acceptable for what you're trying to do, you'll need PHP to do the dirty work and send the 301 redirect. _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
thinkr -
Joined: 24 Oct 2013 Posts: 15 Location: California
|
Posted: Mon Dec 15, 2014 10:05 am Post subject: |
|
|
thanks for this great reply, will get back to you once I have a chance to test it _________________ If you don't question it then you don't know it. |
|
Back to top |
|
|
|