Jump to content

Rewritten URL is showing the new URL in the browser


davestewart

Recommended Posts

Hi there,

 

I admit, I'm no expert on mod htaccess, in fact I normally use snippets gathered together to make my own Frankenstein's monster of an htaccess. So my question, which I suspect may be based on false assumptions is this:

 

I would like to rewrite "tunes" to "files/music", which I am doing as follows:

 

RewriteEngine On
RewriteBase /
RewriteRule ^tunes/?$		files/music [PT,L]

 

I was under the impression that this happened internally to the server, and the user would see "tunes" in the URL bar, but Apache would serve the default file in "files/music".

 

However, it looks as if the request is being completely redirected and the page served is "files/music".

 

Is it possible to do what I think it should be doing, or am I just misinformed?

 

Thanks,

Dave

 

 

Link to comment
Share on other sites

Ah no - that's the PROBLEM!

 

The rewritten URL "tunes" is not being reflected in the links in the page, which are all relative.

 

.htaccess rewrite:

Realpath: /files/music/

RewritePath: /tunes/

 

Page URL:

www.domain.com/tunes/

 

Page links:

Link href: ./some-tune.mp3

Supposed file path: www.domain.com/tunes/some-tune.mp3

Actual file path: www.domain.com/some-tune.mp3

 

So for some reason the "tunes" part of the rewrite is not being reflected in the page links, even though they are relative and the page is showing "tunes" quite happily.

 

Any ideas?

 

Thanks,

Dave

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.