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 have done a webpage with flutter. I have removed the hash symbol from url using setPathUrlStrategy() method. But after hosting to the server the hash is removed from the url but when the page is refreshed it shows 404 error page. I have found different solution like changing the <base href='/'> in index.html to <base href='./'> but done these all solution but not working. I have also tried creating a 404 and .htaccess file and put it in the same level of index.html in web folder of flutter this too doesnt work.
i am use Nginx web server and sample of my web url is as example.demo.com
the sample of my .htaccess file is as below:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
```
If anyone has any idea please help
Ionic 3 PWA: when I visit my pwa website (https://*****.com/pwa/build/main.js), I can see all the source code! how can I protect this file and make my PWA secure?
Please help.
I solved it.
I created ".haccess" file inside "build" directory:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https://(.+.)?mywebsite.com/ [NC]
RewriteRule .*.(js|css|map)$ - [F]
I am using mod-rewrite to make pretty urls. For example http://centraltrack.com/Nightlife/5936/That-Happened/Scenes-From-Friday-Nights-Pop-That-Party-at-Sons-of-Hermann-Hall is using the page http://centraltrack.com/_source/article.php?id=5936. Now when you share a link on facebook it links to the error page instead of the correct page. The Facebook linter pulls in all the correct data, so I'm not sure how to fix the issue.
Again, when you share the not pretty url above, it works and when you share the pretty one, it links to the error page instead. Everything on the site works fine, sharing on Facebook just doesn't work.
Here is how I'm rewriting the links in my .htaccess file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^_source - [L]
RewriteRule ^images - [L]
RewriteRule ^login - [L]
RewriteRule ^([A-Za-z]+)/([0-9]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ _source/article.php?id=$2 [NC,L]
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.