LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 08-27-2007, 01:25 AM   #1
CyberDog3K
LQ Newbie
 
Registered: Jun 2007
Distribution: Ubuntu, Gentoo
Posts: 10

Rep: Reputation: 0
Apache2 mod_rewrite rule for changing file extentions


I want to make a mod_rewrite rule that performs the following, but I'm failing to get the logic in order:

1) Does [filename] end in .XYZ?
2) Does [filename].ABC exist?
3) If yes, redirect [filename].XYZ to [filename].ABC. If no, do nothing.

I could just do a blunt redirect with:
RewriteRule ^(.+)\.XYZ$ $1.ABC [R=301,L]
...which works, but I don't like the idea of doing a redirect to another non-existent file, so I'd like to check if it actually exists first.

I know I can accomplish 1) with:
RewriteCond %{REQUEST_FILENAME} ^(.+)\.XYZ$

and I know I can check for files existing with:
RewriteCond %{REQUEST_FILENAME} -f

The problem is, since the filename is dynamic, and we're not checking for the actual requested file, I don't know how to do a RewriteCond -f against the potential new filename.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2 mod_rewrite isn't working vargadanis Linux - Server 3 11-09-2009 08:21 PM
mod_rewrite - rule to change http to https Firebar Linux - Server 10 06-05-2007 07:29 AM
mod_rewrite rule question jmoschetti45 Linux - Software 0 03-19-2007 07:29 PM
how to add mod_rewrite to apache2 scabrous1 Linux - Software 1 07-07-2006 09:48 AM
changing file extentions Seraph Linux - Newbie 3 09-17-2003 02:42 PM


All times are GMT -5. The time now is 09:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration