Routing YII and CI - .htaccess

I have 2 (working well) applications providing APIs, old one is based on CodeIgniter 2.1 and new one on Yes It Is framework. I need to redirect some actions from old API to a new one. Routing should also provide filtering request methods such as GET, POST, PUT, DELETE etc.
Folder structure looks like this:
ci
yii
router
At first I wanted to redirect all traffic to router/index.php where depending on URI an appropriate app was loaded and started. It worked well with YII, but CI couldn't find it's controllers/models/actions.
Second idea was to use .htaccess, but I couldn't make CI, YII work neither. It's starting, but both of them cannot find it's controllers/models/actions. No errors are printed/logged into apache logs.
When those 2 apps are fired "normally" everything works properly.
I've been changing configuration paths (to absolute ones) and still nothing. I don't want to change those applications a lot, small fixes would be much better.
Also there should be no option to fire an app without checking URI with "routes".

Finally I stayed with PHP router as described in question post. It turn out that CodeIgniter couldn't find it's methods because predefined variable $_SERVER['SCRIPT_NAME'] contained a wrong path, since script was fired from another directory. I had it overridden in router file and everything seems to work properly now.

Related

Issues regarding reloading a react-based webpage

I'm a student working on a project to benefit other students, and I am currently facing a problem with reloading with any other url than the main path.
The webpage is written from scratch (more or less) in React with no backend, but I still hoped that it would work. I am using react-router to change sub-directories.
I have understood that there is a difference between server- and client-url's, and that this issue most likely is related to that. In the app's main directory "webpage.com" everything works fine untill the page is refreshed. If a sub-directory such as "webpage.com/link" is "called" directly, I recieve an error. You can go and try for yourself btw.
Does anyone know of a nice way to fix this? Do I need to implement something like Node.js to fix this? If so, how? I would prefer not to use a hot-fix such as redirecting all sub-directory calls (such as "/link" (an actual page) or "/kejrngo" (jibberish) ) to "/".
I've cloned your project locally and it seems you have a problem with the server. As you said yourself it seems that only open url for your page is http://ifistudenter.no where at the beginning all application is rendered. After you try to refresh the page you are looking for a path that isn't available on the server and that is the reason you get 404.
What seems to be a problem is React Router itself with Apache server:
Please look at this: https://www.malikbrowne.com/blog/using-react-router-with-apache hope it helps

netlify Deployment issue: netlify.toml settings for SPA

Disclaimer: I would ask this using either a.) some sort of support system on Netlify, b.) on a Netlify live chat session or c.) via their support community but a.) they don't let you, b.) they don't have one and c.) you can't currently create accounts or authorize from Netlify itself. (Seems like as an organisation, they don't really understand what would really nudge you into making you pay for a service).
Anyways, I am having an issue with deploying an Vue.js SPA with VueRouter via a netlify.toml configuration. The issue is, all internal routing is not being handled by the SPA. My solution has always been to stick a netlify.toml config file in the root of the repository that I am deploying from, with the following:
# The following redirect is intended for use with most SPAs that handle routing internally.
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
Yet, every internal route I visit gives me:
The exact same repo, but deployed on my personal plan 4 months ago (which has the same netlify.toml config in the same location) works fine. The application is also working on the current deployment branch locally. The routing is not broken. Has anyone else suffered with this inconsistent approach to redirects with Netlify?
So, my specific fix was to do the following:
Add a _redirects file to the public directory of my Vue application, then:
# The following redirect is intended for use with most SPAs that handle routing internally.
/* /index.html 200
Inside that file.
So for me, netlify.toml configuration for redirects is stil broken.
I am seeing exactly this behaviour as well. The netlify.toml contains:
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
But doesn't work. The deployment summary even shows that netlify didn't pick up the redirect config at all:
No redirect rules processed
This deploy did not include any redirect rules. Learn more about redirects.
I just faced this issue like 2hrs ago from now, but the netlify.toml is working fine for me. Make sure you have set the public directory in your netlify setting to '/' (exactly where your netlifly.toml resides) instead of blank or anything else.

IIS URL Rewrite will not work with Integrated mode (but all other action types do)

I have an IIS rewrite rule that I'm trying to use.
When I set the Action to ‘redirect’ its working fine. Likewise, if I select Custom response and set some arbitrary status code, I’m getting that back in the HTTP response, so I know the rule is matching for my URL. However, I need to rewrite this (to act as a reverse proxy) but as soon as I change the action to ‘Rewrite’ it doesn’t take effect.
I have installed the Application Request Routing Module and enabled the proxy under ‘Server proxy settings’ (as per this page http://www.iis.net/learn/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing).
I’ve tried everything from restarting the site(s), the server, IIS, the W3p process and nothing takes effect. I've added the rule at a server level as required and confirmed in the ApplicationHost.config file that it is there and correct.
Any ideas what isn't causing this to fire?
I've seen a few similar posts here on SO, but none of them either have a solution or work for me in this instance.
EDIT: OK, so if I change the application pool from integrated to classic, the rule seems to fire (which is weird as the rule is at a server level!?!). However, My site requires integrated mode to function. Anyone know whats going on here?

CodeIgniter not working on PHP 4 server without .htaccess availability

Basically i developed my app on a localhost wamp server with PHP 5. ON uploading to the actual host i notice that
The server is running php 4.4.9
Everytime i upload my .htaccess file, the server removes it completely.. seems to not be allowed
When i test out the set all i get is a 404 page not found
Any help on how to make it work on this PHP 4 server?
I did a test with CI 1.7.2, default installation.. works on my local server but when uploaded does not work, does this mean that the server does not support it?
I'm sure this isn't what you want to here, but get a new server. Here are the reasons why:
PHP 4 is no longer well supported. It's insecure.
If the server is removing .htaccess files, they are also unsupported on that server, giving you one more reason to move.
Code Igniter runs best with PHP 5 and with an .htaccess file.
The gist of this is you are going to have to hack your code back into the dark ages to get this to work, and then you will still have pretty URL issues and overall system instability. If you can make the switch, do.
If you cannot use .htaccess files with CodeIgniter, in system/application/config/config.php there is a configuration key called index_page. You need to set that to whatever page you have bootstrapping CodeIgniter (usually /index.php)
Then, make sure all your links that get routed through CI either target index.php/controller/action/params... or utilize the URL helper (with site_url or anchor) to automatically put in the index.php
Joe Mills is exactly right in his answer, though. CI works best with PHP 5 and .htaccess.
See CI URLs and CI URL Helper for documentation.
Well i found out how to fix several things
The issue with .htaccess would be to just not use modrewrite as such i put "query_string" option in my path variavable and this works.
The other issue, which was the major issue was that i was using Datamapper library which is a php 5 only library.

Can IIS 6 serve requests for pages with no extensions?

Is there any way in IIS to map requests to a particular URL with no extension to a given application.
For example, in trying to port something from a Java servlet, you might have a URL like this...
http://[server]/MyApp/HomePage?some=parameter
Ideally I'd like to be able to map everything under MyApp to a particular application, but failing that, any suggestions about how to achieve the same effect would be really helpful.
You can set the IIS6 to handle all requests, but the key to handle files without extensions is to tell the IIS not to look for the file.
http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx
You can also create an ISAPI filter that re-writes urls. The user enters a url with no extension, but the filter will interpret the request so that it does. Note that in IIS it's real easy to screw this up, so you might want to find a pre-written one. I haven't used any myself so I can't recommend a specific product that's any different than what you'd find via google, especially as I don't know your specific use case. But at least now you know what to search for.
You can also rewrite your urls using ASP.Net:
http://msdn.microsoft.com/en-us/library/ms972974.aspx

Resources