Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expression for htaccess URL redirect

Status
Not open for further replies.

innovator48

Programmer
Apr 19, 2011
2
IN
Hi All,

I am trying to redirect all files in a particular directory in my web server.

I am trying regular expressions such as
RedirectMatch /data/january\/([a-zA-Z0-9]*).pdf
The expression /([a-zA-Z0-9]*) is trying to find expressions such as "dat35262.pdf".

But its not working. Can you help me out?

Thanks in advance

Ashish
 
Hi

Ashish said:
But its not working.
It works for me :
[ul]
[li]put your code in the .htaccess file[/li]
[li]made a request for [ignore][/ignore][/li]
[li]get redirected to [ignore][/ignore][/li]
[/ul]
Code:
[blue]master #[/blue] wget -S --spider [URL unfurl="true"]http://master/data/january/dat35262.pdf[/URL]
Spider mode enabled. Check if remote file exists.
--2011-04-21 11:39:10--  [URL unfurl="true"]http://master/data/january/dat35262.pdf[/URL]
Resolving master (master)... 127.0.0.1
Connecting to master (master)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Date: Thu, 21 Apr 2011 08:39:10 GMT
  Server: Apache
  [highlight]Location: [URL unfurl="true"]http://www.mysite.com/sample[/URL][/highlight]
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
Location: [URL unfurl="true"]http://www.mysite.com/sample[/URL] [following]
Spider mode enabled. Check if remote file exists.
--2011-04-21 11:39:10--  [URL unfurl="true"]http://www.mysite.com/sample[/URL]
Resolving [URL unfurl="true"]www.mysite.com[/URL] ([URL unfurl="true"]www.mysite.com)...[/URL] 64.136.20.37
Connecting to [URL unfurl="true"]www.mysite.com[/URL] ([URL unfurl="true"]www.mysite.com)|64.136.20.37|:80...[/URL] connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 404 Not Found
  Date: Thu, 21 Apr 2011 08:39:10 GMT
  Server: .V08 Apache
  Keep-Alive: timeout=999999, max=999999
  Connection: Keep-Alive
  Content-Type: text/html
Remote file does not exist -- broken link!!!
Is there anything relevant for such request in your access log and error log file ?


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top