Admin folder not working after adding php router (AltoRouter) - php

I am working on a php project. I am using AltoRouter for this one. In order for AltoRouter to work I need to add this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
to the .htaccess file. What this does is, correct me if wrong, make sure that all request (hyperlink) is first carried to the index.php. No problem till now and everything works great.
I have an admin folder and to login I have to go to
http://www.example.com/admin/
but it shows nothing. I believe the newly added AltoRouter is the cause for this problem. Can any other AltoRouter / php-router user out there help me figure this out.
P.S. Not sure but do I need to Map the Admin Folder as well?

Related

Can Symfony 4 be configured to ignore code installed in subdirectories?

I'm currently converting an old website to use Symfony 4 and the site uses the LiveZilla live chat app.
LiveZilla lives in a subfolder of the site, and is accessed directly using URLs under somesite.com/livezilla. I can't currently access it of course, because I haven't configured a route for this folder. So Symfony decides that this will be a 404.
LiveZilla is essentially a completely separate app living in its own folder here. It isn't dependent on the website hosting it. Is there a way to tell Symfony to ignore certain paths so that code like this can be executed without interference?
I have a sneaking feeling that I need to adjust the way I am looking at this as I can't find anything obvious in the Symfony docs about this, and the framework is pretty well thought out. The best I have come up with so far is hacking public/.htaccess, but it feels wrong somehow...
Your .htaccess file should allow requests directly to existing files, but not directories. See this rule:
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
This means you should be able to access somesite.com/livezilla/index.php but a request to somesite.com/livezilla will redirect to the symfony front controller. So try changing your links to point to actual files within the sub-directory.
There is also nothing wrong with editing the .htaccess file to suit your needs. You just need a condition that checks if the request is to the sub-directory and if so use the same RewriteRule ^ - [L] as above to allow that request to continue.
The following should work if placed after the above rule (reference):
RewriteCond %{REQUEST_URI} ^/livezilla/
RewriteRule ^ - [L]
Or this may be better, place this rule immediately after the line RewriteEngine On(reference)
RewriteRule ^(livezilla) - [L]
The [L] flag means the rule will be the last one used for the request.

Laravel shows 'index of' page only on certain routes

I've noticed some people have had similar issues to this, but the issue has been to do with their vhosts and document roots, but most of the URLS on my site seem to be working fine.
For example, if I create the following routes
Route::get('cases', function(){
dd('here');
});
Route::get('bookings', function(){
dd('there');
});
my.local/bookings works absolutely fine, but my.local/cases just shows me the index of /cases page.
I have rolled back my code to a time it was definitely working, but its still returning the index of /cases page.
Why would laravel randomly stop some routes working?
Heres what i've looked at so far
Rolling my code back to a working state
Dumping composer autoload
Checking php artisan route:list to make sure it exists
Trying a server alias to see if a local IP would work instead
Changing my PHP version
It just wont show me this one page?
Any ideas?! Its driving me mad!
Note - /cases/create works fine, my index / page works fine, it just seems to be a GET request to /cases
The reason for this behavior is the default .htaccess rewrite rule:
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
The two conditions define that the request should only be forwarded to index.php (and therefore Laravel) if there isn't an actual file or folder matching the URL.
It seems like there is a cases folder inside public, so Laravel will not handle requests to that folder.
You can either rename the public/cases folder / the route or remove the first RewriteCond condition. But removing it might have unintended side-effects.

Reroute any subdirectory to script

I am trying to setup simple url routing in a Perl web project without haveing to include a framework just for that purpose. I believe this can be accomplished with an .htaccess.
The plan is for any request to the server using example.com/anysubdirectory/... to be routed to a perl/php script that will parse whatever is contained in /anysubdirectory/... and the parameters following it and then determine where to send the user based on that info.
If example.com without any subdirectory is requested I need to still maintain the default behavior of searching for an index page here.
Since the /anysubdirectory/ will be dynamic i'm not able to predefine that /123/ -> option 1 or /abc/ -> option 2
I am not overly familiar with htaccess other than the typical www and base rewrites.
Any help is much appreciated.
I believe I answered my own question using the following in the root .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ router.pl?action=$1 [L,NC,QSA]
This seems to be working with my initial testing.
I believe this is how it is working:
If the requested subdirectory is not found as a file
If the requested subdirectory is not found as a directory
Redirect this to the router.pl script along with any leftover parameters from the original url.
EDIT: The above is not working completely, this is still redirecting any file that is not found on the server to the router.pl script. Not really the functionality that I am looking for,i would like this to only happen if it is a subdirectory and not an invalid file
Not sure I want any bot thats guessing filenames to be pegging my script on a regular basis.
Please correct this response if any of the above is not accurate.

.HTACCESS RewriteRule not working as expected

I have a magento website, that is currently operating. Within a subfolder of this site, I have placed a 3rd party application that also has its own HTACCESS file to handle routing for its application.
When I access the folder http://example.com/somefolder the screen I expect shows up, but when I navigate to http://example.com/somefolder/newroute, I instead land on a magento 404 screen.
I have traced this to the magento htaccess file, in all cases, unlesss the path physically exists the rewriterule will always send the request to the index.php - this explains why Im getting there.
To fix this issue, I wrote a little rewriterule which I placed in the htaccess file of the magento store. The goal was to add an exception to any request that came through and contained any reference to my subfolder. The thought is now it should hit the path its supposed, then hit the htaccess file, and then route me to where IM supposed to be in this other application. Unfortunately it doesnt seem to work, after adding the rule I end up the same place - magento.
Here is what I've written:
RewriteRule ^(.*somefolder.*)$ $1 [L]
Im not sure what could be going wrong, as I think the approach seems pretty straight forward. Any ideas on how to remedy this situation?
Thanks.
Here is Your Simple Answer.Also Used By me on my site.
RewriteCond %{REQUEST_URI} !^/(yourfoldernameHERE)$

My Codeigniter site works on localhost but not on web server? 500 internal server

I have tested my website on my localhost and it is working fine and all the views/controllers and models are tested.
So I thought I would put it on my webserver and test it there, the website displays however when doing functions like
For example registering or loging into the website does not work:
I checked in firebug it is saying
500 Internal server error
Here is my site, please could you have a browse through the pages , even try registering if you like.
Another thing I noticed on the failed pages is that my favicon is changing to the root domains favicon.
Here is my actual website, its in a sub domain.
Could it be my htacces
Here is the code in it:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
I dont understand why It works on my localhost but not on a dedicated server.
They were both Apache windows servers.
Thanks, for your time.
I think the problem is with your routes. All your pages are with in the domain
http://www.iiios.eu/midas/site/register
But on registering or login it goes to
http://www.iiios.eu/midas/register
without the site in the middle and CI doesnt know how to transfer control to the route. You might wanna check your forms open and action atr for register and login form.
Update
This is your form tag. Check whether you have the method create_member on register class which is in midas directory. My guess is that you have accidentally missed the site there.
I think it should have been
"http://www.iiios.eu/midas/site/register/create_member"
This might be a problem with the routing, see if the referencing to the routes, like when registering, are correct or if you defined routes in the config.php. Is the base_url() defined correctly? Also on the homepage in the sidebar you reference a non-object property.

Categories