Keeping Pages in its own folder? - file

I'm wondering if it would be okay to keep all of my pages in one folder on a site. and leave only the index.html page in public_html?
I know the URL will be like example.com/pages/about.html but theirs a way to change that right?

This is fine. Theres no reason why it should be a problem. And theres no reason why there should be a problem with your URL being example.com/pages/about.html. If you prefer that, then you do that... its fine.
You can always "mask" your URLs using MOD_REWRITE. Look up mod_rewrite and .htaccess files. You will be able to set a rule to "mask" something.html to pages/something.html. Its not hard to do.
:)

Related

Writing links in angular app when using Apache URL rewrites

I'm working on an angular app that is in a structure like this:
/dir1/dir2/myApp
There are rewrite rules in place, so that when someone comes from:
customURL/myApp
they hit my app. When I am in my local environment, the links that I use for routing just look like:
href="#/route"
and that all works fine, but when I hit the app from the custom URL, I end up on my index page and when I click one of the links, it reloads the page and takes me away from my custom URL structure and back to:
/dir1/dir2/myApp/#/route
I currently have fixed this by making all my hrefs look like this:
href="/myApp/#/route"
Then when I come in from the custom url and click a link, the url changes to this and there is no reload:
customUrl/myApp/#/route
That is the desired effect and it all works, but having to add that extra path in to every single href sort of feels wrong, and I'm wondering if there is a better way.
I have read through a lot of documentation and experimented with html5Mode, but this is the only way I have been able to achieve what I want.
If anyone with more experience with this has any tips or even thinks this is a perfectly good way of doing it, I'd really appreciate the feedback.
Thanks!
I would used ng-href="#/route"
very specific case, I can't reproduce on my machine,
so first of all do console.log($location) and see what your host is
if something what you expected, then just play around right href, try with and without '#' or '/'

CakePHP: Can only load index.php, all pages 404 after Cake Bake

I'm trying to bake my first CakePHP application and am unable to get any page to particularly load for me right now. I've updated my config settings for salt,database, etc. and the index.php page tells me that I have configured everything.
So far I've used cake bake all on just one database table so far to make sure it loads properly. I created the Model, Controller, and View for the standard add/index/view/edit pages. When I try to access URL/organizations/index.php I'm hitting a 404 error however.
Is there any troubleshooting someone might have advice for how to solve this one? It is confusing to me that the index.php loads (so it redirects properly when loading the webroot) but trying to view any View pages yields no results. Is there any debug commands I can do to view what the valid pages would be? Or any additional information I can provide?
If you try URL/index.php/organisations or something similar to this and it works, then there is an issue with URL re-writing on the server which you'll need to correct.
I believe if you have things set up correctly you would want to visit /organizations in order to access the index() method of the organizations controller.
In general the ".php" is left off of the URL, as your index.php file initiates all the bootstrapping and routing. This also requires a correct .htaccess setup. Hard to say exactly what the problem is without seeing the app or an error message.
Try in url
URL/organizations/index.php
To
URL/organizations/index
or
URL/organizations/index.ctp
Cakephp using .ctp extension, that means cakephp Template. Please see this link. And also you can see your app\view\Organizations folder. Here all file is with .ctp extension. Isn't it ?

How do I add an admin dashboard feature to my PSK app? And why can't I reach my admin.html page?

As soon as I unzipped and configured the PSK, I tried to add an admin.html page next to index.html from where I'd like to manage my application. However, when I try to reach it via localhost:3000/admin, I get redirected to localhost:3000/admin#!/admin where the original application, the one in index.html shows up, I think because of routing.
I tried removing the hashbang option from page.js, tried changing the / route to /home, all to no avail. The admin.html page doesn't want to show up.
How does one do that? Maybe I need to create another application all together and host it on /admin?
P.S. I am not asking about the security of the approach here. If you want to know anyway, I will try to manage security with firebase (still have to look into it). Thanks.
First, in order to get to admin.html, you need to use ".html" in your URL. So try using localhost:3000/admin.html.
Second, assuming you've made no changes but to duplicate the index.html and rename it admin.html, this will still trigger the routing. You'll need to either create new routing contexts to routing.js in order to control this page, which is a little awkward being it's essentially controlling two separate SPAs, or remove routing.js from your Vulcanized elements.html file so that it can be included only on the main app (index.html). The second option also opens the possibility of having multiple routing.js files so for example your admin.html could essentially become it's own SPA controlled by routing.admin.js.
Good luck!

cakephp add new controller path

Background: I'm new to CakePHP and trying to modify an preexisting project.
When I try to add a new UploadsController it is supposed to handle xxxx/uploads requests right?
However, when entering the url neither AppController or UploadsController, allow index.php to do a dispatch. Files are being called. It goes straight to /uploads which is a directory.
I realize this is a bad design to begin with but trying to fix things one step at a time. Need to authenticate before going to /uploads, and than take action.
What am I doing wrong? I tried to modify routes.php to specify controller but that does not work either.
So as I said I am new and fixing someone else's project. I found that there is a security issue where uploads directory is exposed. So I figured I would add Controller to take care of this. uploads folder was under webroot as a result it was going to uploads folder and was not directing to controller. Thanks and hopes this helps someone in the future.. although kind of doubt it since it was a really bad way to do this to begin with.
With the info you gave this is what I can suggest:
Check to see if the UploadsController is in the Controller folder.
Make sure that there's at least a index.ctp file in Views/Uploads/
Check to see if the UploadsController has a default index() method. This is what www.example.com/uploads/ will hit.

cakephp alias url

The url structure of my cakephp based site is mysite/cakephp/myapp/index.php/controller/action/input_paramaters
I cannot remove index.php from my url, as I dont have access to httpd.conf file.
Anyways, my question is that I just need to change the url of my homepage to something like http://mysite or mysite/myapp
How would I do that?
Thanks a lot!!
The problem sounds to me that you don't have mod_rewrite enabled or Apache AllowOverwrite is not set properly.
If you don't have mod_rewrite then you cannot change the urls with the pretty ones (provided from CakePHP).
If the AllowOverwrite is not set to On. Then even if you have mod_rewrite enabled, the .htaccess files in your directories doesn't take effect.
I don't know which is worst. Speak with your hosting provider and ask for help.
It is not really clear to me which part of the URL changes. CakePHP routing applies only relative from the cake directory. So if you move from http://example.com/foo to http://www.example.org/bar nothing needs to be changed in Cake.
However you might have hardcoded some img/CSS/JS URL-s that needs some work now. I also use the HTML base tag so my app works perfectly fine under various base URL-s.

Resources