I am trying to proxy subdomain to node application which is running on port 3000. It proxies requests to files e.g subdomain.domain.com/jquery.js. It works fine and shows file served by node. But when I try to access the root of subdomain then I guess apache tries to find index.php and fails with message Cannot GET /index.php. How can I make it work so it will serve whatever provided by node app?
my htaccess
RewriteEngine On
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]
RewriteRule ^$ http://127.0.0.1:3000/ [P,L]
RewriteEngine On
DirectoryIndex disabled
worked out
Related
I got the following code in my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^example.de [NC]
RewriteRule ^(.*)$ https://www.example.de/$1 [L,R=301,NC]
</IfModule>
If I call the url without "www" everything works fine! But with "www" it ends with http 500 error!
So on my development Server erverything works fine, with and without www!
On Ionos Server I can do what I want I guess.
I got https://www.expample.de in my Siteconfiguration of TYPO3 9.5 but it doesnt matter. Does anybody know a solution?
I think this is maybe not a .htaccess problem?!
Fix for IONOS hosted TYPO3 installations where adding www to the URL gives a 500 error:
Go to your install tool, /typo3/install.php should be accessible with www in the URL.
Go to Settings and open Configure Installation-Wide Options
Under [SYS][trustedHostsPattern] where SERVER_NAME is set by default, add your domain, for example. .*\.domain\.com (There are other examples given in the install tool).
Save these changes, the website is now accessible with www.
I am using the following configurations in .htacess file
# RewriteRule ^(.*)?$ http://127.0.0.1:3001/$1 [P,L]
# RewriteRule ^(.*)?$ https://127.0.0.1:3001/$1 [P,L]
when I add SSL configurations and use https module in the node server the URL returns 503 services not found but works fine when I remove SSL and use http module.
Problem fixed by removing
RewriteRule ^(.*)?$ http://127.0.0.1:3001/$1 [P,L]
I have a tiny Express app serving on port 35000 on my web server, and it's accessible from mywebsite.com/api using the following .htaccess code (works perfectly, just sends "hello world" to the browser).
RewriteEngine On
RewriteRule ^api/(.*) http://127.0.0.1:35000/$1 [P]
I have set up a subdomain at api.mywebsite.com linked to a separate directory on my server and if I put web files here I can see them at the URL, so that's working fine. I'd like to move my API to api.mywebsite.com so I've created the following .htaccess file in the directory for the subdomain.
RewriteEngine On
RewriteRule ^(.*) http://127.0.0.1:35000/$1 [P]
But navigating to api.mywebsite.com returns a "Not found" error from Express, with a log of 404 index.php. Why is an index.php file expected? I'm happy to at least get the error because that means Express is communicating through the subdomain, but it's not giving me my "hello world" message.
I've had a look at Express vhost from other question but am struggling to understand if that's applicable here or if I'm missing a simple .htaccess rule. Any help would be great thank you.
Just to follow up, this solved my question: htaccess proxy to node app
My .htaccess file in my subdomain directory is now:
DirectoryIndex disabled
RewriteEngine On
RewriteRule ^(.*)$ http://127.0.0.1:35000/$1 [P,L]
RewriteRule ^$ http://127.0.0.1:35000/ [P,L]
I have a shared hosting. The domain mydomain.com points to /home/myuser/www, and I have my app in /home/myuser/www/myapp. I want to access to my node app via mydomain.com, and I think have to redirect via .htaccess file. All my assets are built to /dist folder in the app, with server.js in /dist/server.js.
I have this configuration, but it fails:
RewriteEngine On
RewriteRule ^/myapp$ http://127.0.0.1:4000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/myapp/(.*)$ http://127.0.0.1:4000/$1 [P,L]
In local my app is happily running in http://localhost:4000; how should I configure the /home/myuser/www/.htaccess file?
You can use the mod_proxy for the same. (It is enabled by default in apache, but make sure it is).
The rule will be
ProxyPass / http://127.0.0.1:4000/
ProxyPassReverse / http://127.0.0.1:4000/
The above rule is passing all the root request to internal port of your Node JS app with out user knowing about it (different from a rewrite)
Do restart the apache server for the effects to be seen.
You can also refer the blog post for the same
I am using AWS Elastic Beanstalk to host my website with Load Balancer over some EC2 instances.
I am using OctoberCMS (a flavour of laravel as a framework)
I have setup SSL Certificate over my ELB via AWS Certificate Manager and all is working fine.
But there is a problem.
I want to redirect HTTP to HTTPS.
According to AWS, I got a small .htaccess snippet to do the job:
Redirect to HTTPS
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
However, when a user gets to http://mywebsitesite.com it takes them to https://mywebsitesite.com/index.php hence they start browsing in the manner of https://mywebsitesite.com/index.php/someresource.
Also if you go to http://mywebsitesite.com/someresource, you are redirected back to https://mywebsitesite.com/index.php.
This is not a good experience and I know someone must have encountered this before and is able to redirect to resource properly and remove the index.php
My ELB listener is configured by default to 80 --> 80 and 443 --> 80
Note: I am not encountering a redirect loop.
I'll preface this answer with saying that this is code from the Tomcat Elastic Beanstalk but I believe that it should still work.
I had in my configuration code file:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
This was part of a .ebextensions file that configured the Apache proxy which, in my case, was in front of Tomcat.
You can add the following line in .htaccess to hide the index.php from the url after the redirect configuration.
RewriteRule ^(.*)$ /index.php?/$1 [L]