Can I filter a character out after matching?

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
thinkr
-


Joined: 24 Oct 2013
Posts: 15
Location: California

PostPosted: Fri Nov 14, 2014 8:54 am    Post subject: Can I filter a character out after matching? Reply with quote

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 View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 911
Location: Michigan, USA

PostPosted: Sun Nov 30, 2014 11:44 pm    Post subject: Reply with quote

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:
Code:
/constant/$1$2$3


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 View user's profile Send private message Visit poster's website
pkSML
-


Joined: 29 May 2006
Posts: 911
Location: Michigan, USA

PostPosted: Wed Dec 03, 2014 4:26 pm    Post subject: Re: Can I filter a character out after matching? Reply with quote

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 View user's profile Send private message Visit poster's website
thinkr
-


Joined: 24 Oct 2013
Posts: 15
Location: California

PostPosted: Mon Dec 15, 2014 10:05 am    Post subject: Reply with quote

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 View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group