Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: help with RewriteCond and rewriterule |
|
Author |
|
arunvk
Joined: 30 May 2013 Posts: 2 Location: US, LA
|
Posted: Sun 07 Jul '19 5:03 Post subject: help with RewriteCond and rewriterule |
|
|
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: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Sun 07 Jul '19 22:10 Post subject: |
|
|
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 |
|
Back to top |
|
|
|
|
|
|