Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mod_rewrite apache
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
wifiED
n00b
n00b


Joined: 31 Mar 2008
Posts: 13
Location: South Africa

PostPosted: Tue Apr 21, 2009 1:40 pm    Post subject: mod_rewrite apache Reply with quote

Hey Guys

Wonder if anyone will be able to assist me.

I am wanting to strip the tailing characters from a file name (file.pdf?abcdefhekjkjhsdhsd) so that apache just serves the plain file name (file.pdf)
Can anyone help with a quick way to do it using mod_rewrite in apache?

Any help would be appreciated

Thanks
Back to top
View user's profile Send private message
elgato319
Guru
Guru


Joined: 15 Sep 2005
Posts: 546

PostPosted: Wed Apr 22, 2009 6:58 am    Post subject: Reply with quote

mod_rewrite is not responsible for this.
The appliction that generates the urls needs to be altered.
Back to top
View user's profile Send private message
wifiED
n00b
n00b


Joined: 31 Mar 2008
Posts: 13
Location: South Africa

PostPosted: Thu Apr 23, 2009 9:25 am    Post subject: Reply with quote

Hi there

Thanks but yes i am aware of that. But the reason for this is that the application generates a unique tail on the file so that it no.1 doesnt get cached and no.2 is able to keep track of the unique downloads.

8)
Back to top
View user's profile Send private message
scherz0
Apprentice
Apprentice


Joined: 02 Oct 2008
Posts: 154

PostPosted: Thu Apr 23, 2009 1:04 pm    Post subject: Re: mod_rewrite apache Reply with quote

wifiED wrote:
I am wanting to strip the tailing characters from a file name (file.pdf?abcdefhekjkjhsdhsd) so that apache just serves the plain file name (file.pdf)

You should not have to use mod_rewrite, since by default the mapping is : URL to filename (i.e. without the query string). Do you confirm that in the error log, apache complains about the file "file.pdf?abcdefhekjkjhsdhsd" missing ?
Back to top
View user's profile Send private message
cach0rr0
Bodhisattva
Bodhisattva


Joined: 13 Nov 2008
Posts: 4123
Location: Houston, Republic of Texas

PostPosted: Thu Apr 23, 2009 6:54 pm    Post subject: Reply with quote

i can help with the regex, cant say whether or not this is an appropriate solution


at least in perl or whatnot it'd be something like

Code:

s/(.*)\?[^?]+/$1/


note that regex will break if you have multiple question marks in the Request-URI

this one does not, but isn't as precise

Code:

s/(.*)\?.*/$1/


hope that helps?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
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