I have an Zend Framework application with a subdomain that works well in my local development environment. Now I'm trying to put it on the live location, in a shared hosting environment. I have made the subdomain in DirectAdmin.
This is the default content of the .htaccess in public_html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I have removed the folder public_html/subdomain because I want that everything goes through index.php. But the problem is that if I go to subdomain.example.com I get a 500 Internal Server Error. How can I solve this?
This sounds like a host-specific issue. Typically, if you were running your own Apache server, you would create a VirtualHost directive that would point your subdomain to your application's public folder.
I know some hosts will treat each domain / subdomain as it's separate folder. If your host is expecting you to have a public_html/subdomain folder, why not try making the subdomain folder a symbolic link to your application's public folder?
ln -s /path/to/zf/public/folder /path/to/public_html/subdomain/folder
Related
My self-coded portfolio website is giving me problems when used as an Instagram profile link (let's say www.myurl.com): the Instagram browser displays a 404 error when clicking the profile link. Clicking "Back to Index" on the 404 page shows the website as it should. After checking the URL, I see that Instagram automatically adds a random string to the domain (like www.myurl.com/?fbclid=PAAaa-Vm9q.../) and I assume my website doesn't know how to redirect this. The issue does not occur on a desktop computer, only mobile.
I'm guessing this random string is an SEO tool, which I woefully do not know how to use.
But I need the website link on IG to go through to my homepage without throwing the 404 error, at a minimum. Is there some kind of code / html document / web hosting / dns setting I need to manipulate to get this to work?
I have a feeling this is an issue caused by DNS settings on Cloudflare since I recently set up a proxy with them to use their global SSL certificate.
Some notes about my website in case they are helpful:
hosting on GoDaddy, recently proxied through CloudFlare for SSL certificate
I have the main domain (www.myurl.com) automatically redirect to a subdomain (sub.myurl.com). This subdomain is actually stored in a folder like www.myurl.com/sub/ .
Website is a CMS built on PHP 5
I tried URL shortener services as a stopgap measure. The only one that solved the problem was shorturl.at, but tiny.url and bit.ly still had the 404 issue. I have no idea why.
I looked at the htaccess document in the subdomain root folder, the contents are below. I think the issue may be that the "base" needs to be "rewritten" to the subfolder (www.myurl.com/sub/) but I'm not sure how to correctly change this code:
RewriteEngine on
# Some hosts require a rewritebase rule, if so, uncomment the RewriteBase line below. If you are running from a subdirectory, your rewritebase should match the name of the path to where stacey is stored.
# ie. if in a folder named 'stacey', RewriteBase /stacey
#RewriteBase /
ErrorDocument 404 /404.html
# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !public/
RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]
# Add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]
# Rewrite any calls to /* or /app to the index.php file
RewriteCond %{REQUEST_URI} /app/$
RewriteRule ^app/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?$1 [L]
# Rewrite any file calls to the public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.+)$ public/$1 [L]
I'm very much a beginner with webhosting / coding / etc so will appreciate an idiot-friendly explanation!! Thanks in advance.
I've built a new site for our company, whom I recently started working for, and deployed it on a separate subdomain (http://site.mysite.com) to not interfere with some URLs that need to remain on the old subdomain.
The old HTML site (http://www.mysite.co/site) was, for some weird reason, placed inside the public/ folder of a Zend application, as public/site. We want to redirect this site, which used to be available on http://mysite.com/site folder, to our new site at http://site.mysite.com
I've edited the existing .htaccess file, inside the Zend public folder so it looks like such:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]
# These four lines are my only alterations to this file...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(apps|site).* [NC]
RewriteRule .* http://site.mysite.com/ [R=301,L]**
RewriteRule ^cart/selectaddress$ https://%{SERVER_NAME}/cart/selectaddress [R,L]
Redirect 301 /photobook-sa http://www.mysite.com/photobooksa/
Redirect 301 /photobook-SA http://www.mysite.com/photobooksa/
Redirect 301 /photobookSA http://www.mysite.com/photobooksa/
RewriteRule ^channel\.html channel\.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
php_value session.auto_start 0
RewriteRule ^.*$ index.php [NC,L]
Header append P3P "CP=\"HONK IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA\""
AddDefaultCharset UTF-8
The idea is to trap http://mysite.com/apps/, http://mysite.com/apps/whatever and http://mysite.com/site/ and redirect these all, unconditionally to http://site.mysite.com
The problem is, the redirection only works for /apps and apps/whatever, not for /site. So I discovered the public/site folder, which strangely hosts the company site as a HTML only site, within a Zend project folder structure.
Problem is, when I delete this folder, the whole mysite.com and www.mysite.com domain fails, but for example mysite.com/apps still manages to redirect to site.mysite.com
So I tried editing public/site/index.php to look as follows:
<?php
header('Location: http://site.mysite.com'); exit;
and it works, but only for a few requests, then I get a server error.
I also tried adding a .htaccess inside public/site/.htaccess with the following:
Redirect 301 http://site.mysite.com
which also, works initially, but then fails with a server error after a few requests?
I have no idea what's up, no clue as to why the virtual host is dependant on the public/site folder to work, which not even mentioned in the virtual host setups.
I grepped all the controllers in the Zend application/controllers folder to try and see if I can find anything that remotely mentions this /site folder, but no matches found.
I'm pulling the hair out of my scalp with this strange behaviour, can someone please help?
Also last point, this is an Amason AWS server, which I'm not entirely familiar with, could it be that this server has something funny going on, that's non-standard in terms of Apache configuration, DNS setup or something mysteriously automagic?
We've not been able to resolve this issue, and unable to figure out why our methods work only for a few minutes. I'm suspecting something weird happening with Amazon AWS.
The only way we could fix, was by adding an index.html inside the culprit /site folder, using a small JavaScript snippet to redirect the site from the client side.
I have a Zend Framework application I've been working on my local machine, I've deploying it to a server but having .htaccess issues because some but not all routes fail with a "Page Not Found". Very weird that I can't access some controllers.
My .htaccess is:
RewriteBase /~user/path/to/app/public/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
This error does not occur on the local machine, only on the server. The only thing I can see that is common to the controllers that have a "Page Not Found" error on the server is that the Controller names are camel case.
Controllers that work: CustomerController, InvoiceController, StockController. Controllers that fail: SuppliersStockController, StockTypesController.
If I try to do something like 'www.route/to/app/stock-types/' or '/stock.types/' I get an "Application Error".
You are seeing the effect of a case sensitive file system.
When you go to /stocktypes/index, ZF will look for StocktypesController.php and succeed on case insensitive systems like Mac OS X and Windows. On Linux however, it will fail.
If you go to /stock-types/index, then ZF will look for StockTypesController.php and will find it on Linux.
If ZF finds a CamelCased controller name, then it will look for a view folder with a hyphen.
I am starting a Zend application and I need to put it in a sub folder like this:
/subfolder
application
public
...
I did the following:
I set the base url in application.ini:
resources.frontController.baseUrl = "/subfolder"
I moved the .htaccess from the public folder directly into /subfolder, while changing the htaccess as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [NC,L]
That's all I did. And everything works as expected. I can add controller blog with action view and can access it by calling:
/subfolder/blog/view
the url view helper and stuff work right too. The only thing that does not work is the default controller. So when I enter:
/subolder/
I get 403 (forbidden). If I enter
/subfolder/index
...it works. What am I missing?!
Thanks in advance!
teebee
you do not need to make any change in your zf public folder, just create an .htaccess file into the "/subfolder" directory with the following lines
# Rewrite rules
RewriteEngine on
RewriteRule (.*) ./public/$1
Replace
RewriteRule ^.$ public/index.php [NC,L]
with
RewriteRule ^.$ http://addressto/index.php [R=302,NC]
or
RewriteRule ^.*$ /public/index.php [NC,L]
i'm not sure if putting ZF folders other than public into publicly accessible folder is right.It will impose your site on security flaws. You must put ZF'S public folder' contents into your server`s public folder and put other folders into a non-publicly accessible folder.If you need more that one instance of your ZF application you may use Zend module system.Please refer to zend online documentation for more details.
I have a server, where I have uploaded my work in zend framework(in a subdomain). the folder name is 'visit'.
So, When I go to: http://mysitename.com/visit, it shows a directory structure:
Parent Directory
application/
docs/
library/
nbproject/
public/
tests/
But when I go to: http://mysitename.com/visit/public, i get the index page of my project.
But I want to get my index page , when I type: http://mysitename.com/visit
can you please give me the correct htaccess it need?
Also, these other approaches to deploying in shared hosting can help:
Zend Framework on shared hosting
http://www.alberton.info/zend_framework_mod_rewrite_shared_hosting.html
http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/
http://www.ttech.it/en/article/2010/03/zend-framework-all-projects-files-on-document-root/
In particular, an answer by tharkun led me to write it up in more detail in a blog post.
You can do this with the following rule set, which is in part a partially modified version of the one described in the documentation.
.htaccess file in /visit:
RewriteEngine on
# Guard against people visiting /public/ directly
RewriteCond %{THE_REQUEST} ^[A-Z]\s/visit/public/
RewriteRule ^public/(.*)$ /visit/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
# Make sure we've rewritten to the ./public/ directory already
RewriteCond $0 ^public/
RewriteRule ^.*$ - [NC,L]
# The index file is now at /visit/public/index.php
RewriteRule ^.*$ /visit/public/index.php [NC,L]