I have a TYPO3 7.6.x multi-domain setup and need to place different static files on the root level of each domain (WWW.DOMAIN.COM/file1). Is there a way to map a folder somewhere in the tree in a way that everything in it appears at the root level of the domain? I want to use this for favicons and the like. I know there is other ways (e.g. meta tags) to deliver these files but one folder to place them is generally the recommended way and it keeps the html source code clean.
Any advice is appreciated.
You can only symlink one file by file or a folder, it is not possible to symlink each file of an directory into an other directory.
There are commands to symlink all files in an directory to another, but each time you add an file you have to rerun these commands. Look here.
Maybe you can run an cronjob to run these every hour or every five minutes. But I think a simple upload to the root should be much easier.
Edit:
Now I have understand it ^^
You can make rewrites depending on the domain in your .htaccess:
RewriteCond %{HTTP_HOST} ^(www\.)?domain1.tld$
RewriteRule ^favicon.ico$ /typo3conf/my_template/Resources/Public/DomainA/favicon.ico [L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain2.tld$
RewriteRule ^favicon.ico$ /typo3conf/my_template/Resources/Public/DomainB/favicon.ico [L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain3.tld$
RewriteRule ^favicon.ico$ /typo3conf/my_template/Resources/Public/DomainC/favicon.ico [L]
Related
How do I make the redirects in go_router package work correctly when uploading the website to cPanel? For example when I type in the url www.website.com/contact I need it to open the /contact route on my app. It works great when hosting locally and when I host it to Firebase with the rewrites file (https://stackoverflow.com/a/71956918/12099062), but I am unable to make the redirects work in cPanel.
I have tried configuring the Redirects in cPanel, but if I redirect any page to www.website.com it just moves to the main page and if I redirect it to www.website.com/index.html it just shows Exception: Bad State: No Element.
Any help is really appreciated!
I managed to make it work by following a React app tutorial (Deploy / Host your React App with cPanel in Under 5 Minutes). I needed to manually add these contents to the .htaccess file in cPanel File Manager public_html folder (Note: You need to enable "Show hidden files" in order to see that file and if it does not exist, just create it).
Here is the complete .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
I was able to successfully deploy my web app in apache server(wamp) locally. So initially my URL looks like http://somehost.com/dshrestha/ and I can navigate to various routes for eg. http://somehost.com/dshrestha/home, http://somehost.com/dshrestha/contact etc via navigation links but then when I refresh the page on any of the routes, I get 404 Not Found error.
How can I overcome this issue? i even tried to redirect all requests to index.html by creating htaccess file but no luck. Thanks.
I had the same problem, but I found the solution in the next answer:
https://stackoverflow.com/a/28630973/4425050
Change the locationType from auto --> to hash
Ok turned out it was an .htaccess thing I had to fix. Added these in my .htaccess to get things working
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !(?=jpg|png|gif|js|css|pdf|docx|htm)
RewriteRule ^(.*)$ index.html
its an old post, however, to make sure you can use bootstrap glyphicon and any other file that pg|png|gif|js|css|pdf|docx|htm, replace
RewriteCond %{REQUEST_FILENAME} !(?=jpg|png|gif|js|css|pdf|docx|htm)
with this
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
This question already has answers here:
zend framework deployment in server
(2 answers)
Closed 10 years ago.
I am on shared hosting server and I am going to place zend application there but I can not touch httpd.conf file to make a virtual host as it is shared hosting and they do not allow me to do it.
If I keep index.php file and .htaccess in the public folder I have to make a virtual host to hide the public from the url.
So, I though that I can put the public folder files (index.php, .htaccess) in the site root thus I don't need to create a virtual server for this and my site is accessible without the need of public in url.
Is there anything make my site unsafe if I put index.php file out of public folder?
I speak English not well, so sorrry. Somethings i copied from other posts to describe things i want to explain.
I have tried this way but it still doesn't work, when i type localhost/public/zend/, it returns "Object not found"
Directory structure:
zend/
application/
library/
public/
index.php
.htaccess
.htaccess
content of .htaccess in public folder:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
content of .htaccess in root folder:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Well you wont be able to access index.php in that case. If you cant put things not in the web root then the best bet is to configure ZF to use a folder other than public as your doc root so your layout might look like:
application/
library/
modules/
public_html/
index.php
js/
css/
images/
The "public" folder is an important key feature of the Zend Framework because it confines Apache to only read files in that directory. You should not have anything else than the public folder accessible via HTTP and moving the index file introduces easy threat of being vulnerable to exploits.
Check this out this link it might be helpful.
And if you are using Cpanel this here might be useful.
Is possible to have .htaccess and index.php without any kind of problems in the Apache's htdocs dir.
It's not mandatory to have a folder called "public", just to have the public part (public directory( and application part (the rest of project files) in different directories. The application part must not being accesible from the user's browser (so place it outside of the Apache document root)
There are many ways to make ZF work without having the ability to map the virtual host to a public folder.
This answer highlights many of them.
Personally, when I'm stuck with shared hosting and I am unable to remap, I tend to do the following :
Keep the contents of the public folder (index.php, .htaccess, public assets like css, js, img, etc) up at the host-provided doc root, and
Push the rest of the application down into a folder like _zf to which I add a Deny All directive in an .htaccess file. Then I modify the APPLICATION_PATH setting in index.php to point to _zf/application.
That's it.
Full details here.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Zend - How to install on WAMP
I have a website created in Zend Framework.
But when iam trying to load in wamp server it is not working correctly.
If there is any set up steps in wamp for zend?
How can setup zend frame work website in wamp server?
In this site there have a login page , when i login correctly it will displays a white page only nothing will be loaded.
What is the reason?the login page is displayed correctly but after login the site is not loaded
Make sure that the rewrite_module is enabled Go to Wamp Server -> Apache -> Apache Modules
Deploy your project to a folder in your document root folder, default www for example projectname
You need to change the .htaccess in the public folder of your Zend Application as follows
RewriteEngine On
# the base for rewriting the files, this is relative to the document root being used
# for local environment use the name of the project folder
RewriteBase /projectname/public/
# Rewrite conditions for the Front controller
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Access your project as http://localhost/projectname/public
I am using Zend Framework and running into issues where myAction() is called twice. After spending many hours looking for other developers with same experience it seems that there are some main issues that people have solved. Either:
-*.css / *.js file or favicon is not found, so I tailed the apache access log fiel with no thing to show for.
-Then I looked for images that did not exist that were referenced in any css. No luck there as well.
-Lastly I found that people using ZFDebug were running into issues, but since I am not using that or have it installed this is something I cannot troubleshoot.
Please if anyone has any idea of what I can try to resolve the issue I would grateful if you would share this with me.
UPDATE:
kinghfb and Phil,
Thank you very much for your replies.
Your information was very clear and all very good suggestions. I double checked all my css and js files and since I don't really use partials but have view helpers that was an easy check as well. All were at least 4k and none were empty. I also, tried what Phil suggested changed:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
to:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Which also did not solve my problem. I did fail to say earlier that when I disable layout in the action it runs only once. Any other suggestions?
I ran into this same problem, and found solutions similar to what you describe (Zend Debug, favicon.ico etc etc). However, I wasn't running any of these things.
What you need to check is that all the requested files actually exist and are greater than 0 bytes (JS, CSS, images, and -importantly- template files), otherwise the system won't find it and try to Bootstrap the app again. This is because the default mod_rewrite settings only bypass the bootstrap when the requested file is > 0 bytes.
Hopefully that's clear and helped :)
Thanks really much for this answer kinghfb, you saved me lots of time...
In my layout file I had 3 of those (that causes the controller to execute 3 times) :
<img src="path/path/file.jpg" >
I had to do this instead :
<img src="/path/path/file.jpg" >
The way I've found this is by writing to a file in my controller (doing only echo won't show it)