Solved

Modrewrite

Posted on 2007-12-03
7
245 Views
Last Modified: 2010-03-04
Hi, I want change with mod rewritte all the entry request like this:

http://thumbs.domain.com/attachment.php?id=12345&name=005.jpg

By this:

http://thumbs.domain.com/1/2/3/4/5/005.thumb 

Ineed the code to do this in apache,

Thanks!!
0
Comment
Question by:admincentralmail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 20395164
I think You need to use external program for that.

RewriteEngine On
RewriteBase /
RewriteMap splitDigits prg:/path/to/splitter
RewriteCond %{QUERY_STRING} id=(\d+) [AND]
RewriteCond %{QUERY_STRING} name=(\d+)
RewriteRule ^attachment.php ${splitDigits:%1}/%2.thumb [L]

And the /path/to/splitter should be executable and should look like
#!/usr/bin/perl
$! = 1;
while (<>)
{
 print(join("/", split(//, $_)));
}
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20395179
#!/usr/bin/perl
$! = 1;
while (<>)
{
 print(join("/", split(//, $_)) . "\n"); #forgot the newline, sorry
}
0
 

Author Comment

by:admincentralmail
ID: 20395232
I have a old php to send the thumbnails, but I want link direct to the thumbnails.

the .thumb is a .jpg

With this code I can put in the apache config and apache rewrite and convert:

http://thumbs.domain.com/attachment.php?id=12345&name=005.jpg

to this:

http://thumbs.domain.com/1/2/3/4/5/005.thumb 

??
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 43

Expert Comment

by:ravenpl
ID: 20395936
I haven't tested that, but should work. Test it.
0
 

Author Comment

by:admincentralmail
ID: 20397014
Do you know the code to do this:

#!/usr/bin/perl
$! = 1;
while (<>)
{
 print(join("/", split(//, $_)));
}


Without a perl, only with RewriteCond
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20397691
No, thats why there's RewriteMap option.
RewriteCond/Rule only matches some patterns - do not modify them.
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 125 total points
ID: 20398266
> id=12345
If You know it's always going to be 5digits, then
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} name=(\d+) [AND]
RewriteCond %{QUERY_STRING} id=(\d)(\d)(\d)(\d)(\d)
RewriteRule ^attachment.php %2/%3/%4/%5/%6/%1.thumb [L]
otherwise You need some generc code (like the one I provided)
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question