logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: help with RewriteCond and rewriterule
Author
arunvk



Joined: 30 May 2013
Posts: 2
Location: US, LA

PostPosted: Sun 07 Jul '19 5:03    Post subject: help with RewriteCond and rewriterule Reply with quote

Hi, I have been going crazy trying to figure this out.

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.
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Sun 07 Jul '19 22:10    Post subject: Reply with quote

Hello,

what about
Code:
RewriteCond %{REQUEST_URI} !^en/(.*)
RewriteRule ^en/(.*)$ $1 [QSA]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ http://localhost:3000/$1 [P,L]


Best regards
Matthias Very Happy
Back to top


Reply to topic   Topic: help with RewriteCond and rewriterule View previous topic :: View next topic
Post new topic   Forum Index -> Apache