Rewrite rules

Topics: Developer Forum
Feb 1, 2010 at 4:30 PM

What would a rewrite rule look like for this case:


i tried

RedirectRule ([/website/]*)abc([/somePath/]*)        $1/$2




Feb 1, 2010 at 7:20 PM

RewriteCond %{HTTP_HOST} ^localhost$
RedirectRule ^/dnn/(.*)$        http://localhost/website/$1 


what's wrong with this?

Feb 1, 2010 at 11:40 PM

I think you have things backwards. And also I think you may be a bit unclear on how URL rewriting works.

The first argument to the RewriteRule is the pattern to match against the incoming request.  Another way to think of the "Incoming request" is - the "External URL" - this is the URL that people type in their browser address bar.  I think you want them to type the simple URL, is that right?  The one without dnn or abc or whatever.   I believe you want to use IIRF to map that simpler URL to a more complex one that is used internally internally, by the server.  Is that right?

If so, then you want to do something like this:

##           external URL     internal URL
##           (anything)       (prefix with specific URL path elements)  
RedirectRule ^/(.*)$          /dnn/website/$1

Notice that there is no scheme (http) or server (localhost) or port (80), included in the replacement string. The replacement string for a rewrite is the URL path that is used for the request. Since you read the documentation, you're clear on the fact that there is no server name or scheme used in the replacement string for a rewrite.

But to be honest I am not sure what you want, because you gave me only "X expected Y", and there are not enough verbs in that kind of a statement for me to understand what you really want.

Feb 1, 2010 at 11:47 PM

thank you for your response.

my solution was similar to yours in that I used ^/abc/(.*)$ to match what I was looking for.

I just wanted to strip the abc out. should have been more specific.