LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2019, 10:03 PM   #1
arunvk
Member
 
Registered: Nov 2005
Location: India
Distribution: Fedora 29
Posts: 197

Rep: Reputation: 30
help with RewriteCond and rewriterule


Hi, I have been going crazy trying to figure this out in apache/httpd.

lets say I have an incoming request site.com/en/resources/help.jpg

I would like to test if the file exists by ignoring the the /en part. /en folder is not present in documentroot.

Below works only if there is an en folder. Is there way to remove /en part and then test if a file exists?

Code:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ http://localhost:3000/$1 [P,L]
I did try to experiment with expressions and If module but cant get it working.

Last edited by arunvk; 07-06-2019 at 10:03 PM. Reason: didnt mention software
 
Old 07-08-2019, 04:08 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,520

Rep: Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774Reputation: 1774
Quote:
I would like to test if the file exists by ignoring the the /en part. /en folder is not present in documentroot.
Below works only if there is an en folder. Is there way to remove /en part and then test if a file exists?
If you want to test regardless of the existence of /en, why don't you use just:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mod_rewrite problem with RewriteCond SkyerSK Programming 8 05-27-2011 01:39 PM
Apache rule loop - make RewriteCond explicit timmywo Linux - Software 7 04-18-2010 08:50 AM
Doubt about RewriteCond? your_shadow03 Linux - Newbie 8 12-18-2009 03:29 PM
Correct Apache RewriteCond to stop proxying ... curtisa Linux - Security 1 07-21-2009 10:38 AM
RewriteCond & Rewrite Rule Problemo sea-bass Linux - Server 0 04-07-2008 10:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:05 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration