I'm about to start running three different environments of our PHP application - Development, Staging and Production. Some of our customers will get access to Staging to help us test new features with real customers before it his production.
Our application is running on AWS EC2 though an elastic load balancer using HTTPS only. I need a way to allow users to go to https://mydomain.com/staging and be redirected to the staging environment (would still show https://mydomain.com/staging in the address bar, but they'd be getting content from a different set of servers). There will be some code in Staging that will ensure their account has been approved for Staging access and will allow them in or redirect them to the main application.
I can't seem to figure out how to write this in .htaccess. I've tried a number of things I've found online and haven't gotten it to work. I am beginning to think it may make more sense to have a real directory even in the production environment called 'staging' and have an index.php file inside that checks their account and redirects them based on the result.
However, I'd like to avoid having to purchase another SSL certificate for this, so instead of using a subdomain for staging, I'd like to use a virtual directory. Does that make sense?
Thanks in advance.
You need to enable the use of .htaccess in your httpd config file (you can do so by finding the line in your conf file that has AllowOverride None and change it AllowOverride All) and then place a .htaccess in a folder in your html folder called staging with the following line
Redirect /staging http://whereverYourStagingEnvoIs
I would recommend using a subdomain instead of a subdirectory, staging.mydomain.com
Then in your host records for mydomain.com you could point staging to whatever server you like.
Related
I have a virtual machine setup to host 4 domains, running fine (non-prod environment). There are image files and pdfs common between all domains. To save uploading the same files to each domain I want to have folders above the root folder of each domain i.e. all folders /var/www/html/in here (domain1,domain2,photos,pdf,dbconn, etc), I have done this with my PHP database scripts and they work fine, getting forbidden/permission error when I click on links. From my research, I've identified I need to modify httpd.conf and or httpd-vhosts.conf not totally sure which or both and not sure what the modification should be, also believe I should steer away from htaccess. (I have access to these conf files, I'm a PHP developer and don't usually play with Apache) Hoping this makes sense to someone and able to get some help. Thanks in advance.
grant access to whatever directory the images and pdfs are stored in, access can be granted in each virtual host individually or in your main apache config file once, something like this...
<Directory "folder/subfolder/noobfolder">
Grant access all
</Directory>
Currently I can call my app (PHP) with the following URL:
http://localhost/app/public/index.html
Is there some way to hide the public in the url, so I can access the app just with http://localhost/app/index.html?
With the .htaccess file it should be possible. I am using XAMPP.
Don't use mod_rewrite for this. Instead, just set your web server's configuration such that the DOCUMENT_ROOT is pointing to public and not a directory above it. This will have the desired effect as well as preventing your server from handing out things that aren't intended to be public.
Edit: Note, this requires name-based virtual hosting and will require you do effectively dedicate a domain name to your app, but that's not a big deal.
I'm having a strange problem with a new PHP page I´m writing. Everything seems to be loading/redirected to the domain root page.
domain.com loads fine
domain.com/page or domain.com/page/index.php always loads "domain.com" while retaining the /page/index.php in the browser URL.
Even domain.com/some_random_text loads "domain.com"
I suspected the .htaccess file, but there is none to be found. There are no redirects in the PHP code.
If I remove the domain.com/index.php file I get an Internal Server Error when opening domain.com/page/index.php
This domain did have Wordpress installed, but I did uninstall that via cPanel.
First thing to notice is that the .htaccess file can be anywhere in the path that is handled by Apache. So check everywhere. This kind of redirect could be made only like that.
This can only be done by Apache, so you might also like to check the apache config if you are running on a virtual machine or dedicated server.
Also, not that it might have been a wildcard redirect, added by the cPanel, so check those settings. Though I think those actually just modify the root .htaccess file.
Based on the data you provided I cannot say more, but I don't think this is a common issue.
I wrote a very simple Magento module that sends an email but doesn't use Magento's core emailing system. I'm using ajax to POST to email.php
I've tested this to oblivion in three separate environments: local, development, and staging. It works flawlessly on all three.
Now when I took these changes live on a fourth server, all post requests return the following:
POST http://mydomain.com/dir/path/email.php 403 (Forbidden)
And all post requests log the following to my error log:
client denied by server configuration: /var/www/vhosts/mydomain.com/httpdocs/dir/path/email.php, referer: http://mydomain.com/myCategory/myProduct
Everything appears to be exactly the same between the four servers. I've checked permissions and httpd.config as well as .htaccess files.
I can add the following to the /apps/.htaccess to get everything to work on live, however I can't keep it this way for obvious reasons.
<Limit POST>
order deny,allow
deny from all
allow from all
</Limit>
I thought there was a possibility that the magneto root .htaccess file could be the culprit but the staging and dev servers are clones of the live site.
Basically, I've checked everything I can think of on the server side of things. I'm completely perplexed as to why my module would work on three separate servers but not on the live site. Is there anything file related that could be causing this? Maybe firewall rules? The generic error in my log file is making this difficult to troubleshoot.
I got this task form school, to make a PHP web application. But I don't really understand what this requirement might mean
It should be possible to run this application outside the domain root
e.g. sample URL: http://localhost/task/.
I searched a little bit on the internet but was not able to find anything that I could understand ?
I have wamp, and the folder where is my sites is wamp/www/task
When they say "outside of domain root" it means that you should not be forced to go to
http://localhost/yourfile.php
but you could put it in a subdir, like
http://localhost/task/yourfile.php
What they want you to do is harder to guess, but it could mean that you need to be able to run it in any subdir, so take care of you imports to be able to handle that (e.g.: not hardcode the dir you're working in).
Domain root seems to be at localhost, this just means it should be easy to rename your web application folder and make it still work at anywhere.
# http://localhost/task
$ cd wamp/www/
# http://localhost/task2 - should be accessible without you needing to change anything
$ mv task task2
From technical point of view, you should use relative path for all your links and images as well as external resources such as javascript / css files
you can set vitual host for your web server & access your PHP Application likw www.oorja.local
in the wamp server, just add below code at end of your httpd.conf file, which allow you access your PHP application without localhost, Document root and Directory have your physical pathe of your application directory.
ServerName oorja.local
DocumentRoot E:/LAMPSYSTEM/wamp/www/oorja/public
<Directory E:/LAMPSYSTEM/wamp/www/oorja/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>