Forum Moderators: phranque

Message Too Old, No Replies

Url rewriting question

url rewriting question

         

sham1321

7:11 am on Dec 4, 2009 (gmt 0)

10+ Year Member



Hi all,

I am new to url rewriting, i need your help .

i am handling a ecommerce site,
i need to redirect this url

[mysite.com...]

to

[mysite.com...]

the img123 folder and img123.swf are parameters which is passed from a js .

how write a url rewriting for this.

i tried
RewriteRule ^flash[/](.*)[/](.*).aspx$ img/flash/$1/$2.swf

but this is not working.

please help me out.
Thanks in advance.

g1smd

8:10 am on Dec 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have used the word 'redirect' and the word 'rewrite' in the question.

Which one of those very different things do you want to do?

A redirect tells the browser to go fetch a different URL, using a second HTTP request. The browser URL bar changes to show this new URL.

A rewrite silently fetches content from a different filepath within the server compared to that suggested by the path part of the requested URL.

See also many previous threads that explain why using multiple (.*) patterns can slow your server to a crawl as the pattern might have to be evaluated thousands of times before a match is found.

sham1321

8:41 am on Dec 4, 2009 (gmt 0)

10+ Year Member



Sorry for that its rewrite

[mysite.com...]

to

[mysite.com...]

i need the browser show the above url instead of the orginal

Can anyone write the url writing for this

please help me out.
Thanks in advance.

g1smd

9:06 am on Dec 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Which one is the URL that users will 'see' and 'use'? It's the one that will be in the links on the pages of your site.

What is the internal server filepath for that content? It will be just a server filepath, no domain name will be included.

Example. "I want users to use the URL example.com/cats.html to access this content, and the content will reside inside the server at the /animals.php?type=cat filepath."

sham1321

9:18 am on Dec 4, 2009 (gmt 0)

10+ Year Member



Hi,

Actually my real path is,

[mysite.com...]

the above one will be generated from the js function,when the user click a button

function photogallery(item)
{
var mySplitResult = item.split(".");
window.open("images/flash/"+mySplitResult[0]+"/"+item, "newWindow");
}

when the user click the button i will get the

[mysite.com...] path.

but i dont want to show the above url instead of i need to show the user to see the below url.

[mysite.com...]

Many thanks

jdMorgan

4:02 pm on Dec 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are confusing server filepaths with URLs, and they are not the same thing at all. It is impossible to code a solution until these two terms are understood and used properly.

Whatever URL you want to "show up in the user's browser address bar," that is the URL that your HTML page (or document.write JavaScript code on that page) must link to. Linking from a Web page is what defines a URL, and that URL is what shows up in the address bar when the link is clicked or activated by a JavaScript event.

That URL will then be requested from your server when the user clicks on that link or when a JS event is fired that causes an HTTP request to be sent to your server.

Once the HTTP request arrives at your server, mod_rewrite can be used to 'connect' the requested URL to the correct filepath on the server -- in this case, your actual .swf filepath.

But the link URL that you present on your Web page must be what you want to show in the browser address bar (http://www.example.com/images/flash/flash-img123.aspx) -- mod_rewrite cannot be used to change that. This URL is also the one that will appear in search engine listings, and mod_rewrite can't change that, either. Again, the link on your HTML page defines the URL.

Once this is done, then an internal rewrite from requested URL http://www.example.com/images/flash/flash-img123.aspx to server filepath /images/flash/img123/img123.swf is the last step.

Jim