React Subdomain Goes to Main Site 404 - .htaccess

URLs on my subdomain like react.mysite.com/page1 go to mysite.com/404.html, when refreshed, instead of the appropriate React component.
Can i have a seperate .htaccess for my subdomain? If so what would I write in it so it would look at react.mysite.com and let that handle the rest of the url?
I'm relatively new to React and SPA, so any help would be greatly appreciated.

So you can have multiple .htaccess files.
And the rule is available in this question:
Apache web server doesn't allow me to refresh on /about but on localhost its working fine

Related

Configure Subdomain with Heroku and Google domains?

I want to configure a subdomain on my main website. For example, www.something.com and something.com redirect to the same main website.
I want to add hi.something.com and for this, I used on my nodejs application vhost.
var vhost = require('vhost');
app.use(vhost('hi.something.com', require('./routes/hiIndex')));
//In (./routes/hiIndex) theres just an app.get telling it which page to render when it reaches this URL
When testing it locally, it works, but once I deploy my application to heroku and try to access hi.something.com it doesnt work, it redirect me to the main website, meaning something.com
Do I need to add some extra configuration, perhaps on the DNS settings for google domains or on Heroku?
If so, do I just point it to something.com ??
I have worked with redirect to other websites in form of subdomains but this is my first time trying to make it work from my own application.
You might have a subdomain catch-all redirect which prevents vhost in Node.js from picking up the subdomain. Try adding an A type record in your DNS settings that points to your Herokus server.

IIS rewrite subfolder URL to subdomain content

I'm trying to load content hosted on a subdomain site as a subfolder on the same main domain - I've attempted a variety of IIS URL rewrites with no luck so far. The goal is for a user to go to:
domain.com/subdomain1
which displays
subdomain1.domain.com
but keeps the URL as
domain.com/subdomain1
There are multiple subdomains which I need to do this with.
I have the URL Rewrite module installed and have tried all many of rules.
Any help would be appreciated :-)
A rewrite changes the path on the server only, if you want the URL to change you need a redirect. You can change this on the rule.

URL and Port redirect on IIS

I'm struggling with an issue in IIS 8.5 which is about redirection and rewriting, but couldn't get a solution yet
we have an application driven Webpage running on IIS, but is not manageable.
This application can attached by browser using
http:// 10.172.100.242:81/appname/object?parameter
which is not really customer friendly. Up to the "?parameter" the URL is steady, parameter is changing.
I would prefer to have this url shown to the customer as
http:// appname.domain.com/parameter (best solution) or
http:// appname.domain.com/object?parameter
The combination of redirect and rewrite is too much for my knowledge
The rules I tried didn't work and now I have the hope to get some help from guys with better knowledge than mine...
Thanks in advance
First create a new website in IIS. Then configure as follows.
Inside the website create a folder called "parameter"
Select the "parameter" folder and set the redirect as show in the picture 2

How to STOP redirecting my website to mobile.mywebsite.com in smartphones

I have developed a website www.mywebsite.com and it is ready to go live.
I have used Codeigniter framework.
When I enter www.mywebsite.com from any android/iphone, it redirects automatically to mobile.mywebsite.com and displays page not found error. I dont have any mobile site developed for this. I want to show the main site even on the smartphones.
I am not good at .htaccess file, and I am using default .htaccess to remove the index.php in the url.
I tried creating a subdomain mobile.mywebsite.com and pointed to root path. But same response. I search online, but didnt find anything on how to STOP redirecting.
Thanks in advance.
When I was uploading my local files into the server I was NOT overwriting the old ones assuming the folder is clean and no need to overwrite. But my hosting provider has default .htaccess which is redirecting to the mobile site.
I deleted the old one and gave my .htaccess without the mobile redirection and everything is in place now

Prevent displaying PHP File through URL with htaccess

i would like to make it impossible to open a PHP file directly through an Url but keep it still accessible through jQuery. Right now it is possible to enter this URL in the Browser:
http://domain.com/php/member.php
But i would like to prevent that. If someone types this in the Browser Url than i would like to redirect everyone to http://domain.com with htaccess. But it must be still possible to send variables through the own Website with jQuery to the PHP File.
Thanks :)
If you don't want it access directly put it outside the web root and use a php script to interact with it. jQuery/JavaScript is client side. If it can access the file, then the client will be able to also. You would be better off using PHP to send/receive info to jQuery and hide that file outside the web root so there is no direct access.
You can use this htaccess redirect to generate the code to redirect domain.com/php/member.php to domain.com. You can use a 301 redirect like the one above.

Resources