Wrong paginate links after deployin Laravel app to shared host - php

I used ajax to Load pagination content in its frame. Everything was OK in Local host. For example in http://localhost:8000/exampleroute pagination link for comments section , page 2 is: http://localhost:8000/content/page_comments?page=2 and works well.
But in shared host is: https://example.com/content/page_comments?%2Fexampleroute=&page=2 and links not work.
I guess the problem is related to .htaccess file. so .htaccess contents here:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
What is base problem?

RewriteBase / seems like it could be the issue.
Remove it and compare against https://laravel.com/docs/5.6/installation#pretty-urls. Make sure in your .env file you have APP_URL value set to your application url.

Related

Multiple Choices error page in 1and1

I have done my project using laravel. I want to upload my project on 1and1. I set my directory structure on 1and1 is as '/directory' which contains index.html file which links to the other page in /directory/EngageV1/public/auth/login. but when I visits this page I am getting the error page as,
Multiple Choices
The document name you requested (/index.php) could not be found on this server. However, we found documents with names similar to the one you requested.
Available documents:
/index.html (common basename)
Please consider informing the owner of the referring page about the broken link.
My .htaccess file looks like,
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
</IfModule>
If enter url as /directory/EngageV1/public/ then it shows me the welcome page which I have set in routes.php file for route as '/'. Only this page works fine,I don't know what to do, Please give any suggestion.
Replace default contents in your .htaccess file under your the public
folder with the following.
RewriteBase /
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
If you still have problems look at this tutorial about how to deploy a Laravel webapp to 1and1
I know this is is an very old topic, but it took us some time today to find out what's going wrong on an old 1and1 (now Ionos) server. Turned out, the "multiple choices" page doesn't com from Option +MultiViews / mod_negotiation, but from a module called mod_speling that's running there by default. You can disable it in the .htaccess file:
<IfModule mod_speling.c>
CheckSpelling off
</IfModule>

codeigniter rewriting of URLS not working

In the past, I have got this working no problems at all, but for some reason on my new server I just can't get it to work.
I have the following .htaccess file in the root of my application
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have also enabled mod_rewrite and have confirmed this with php_info()
my site is located at /var/www/html/test
Is it possible that although mod_rewrite is enabled that it is not working and if so, how can I test it?
On some server implementations, you'll need to wrap it within <IfModule> tags.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Also check your httpd.conf file to ensure it has:
Options FollowSymLinks
AllowOverride All
It'd also be worth checking to makesure the .htaccess file isn't being overridden by another .htaccess file.
A simple way to test if .htaccess is working
Simply put the following in your .htaccess file:
deny from All
What this does is deny access to your site from everyone. If you are presented with a 403 forbidden when trying to access the site - the .htaccess file is being included. If not - see above.
I use this on my codeigniter setup
RewriteEngine on
# prevent these directories from hitting CI
RewriteCond $1 !^(index\.php|images|assets|robots\.txt|crossdomain\.xml)
# route everything else to the index.php
RewriteRule ^/(.*)$ /index.php/$1 [QSA]
(my setup is done in the virtualhost of .conf and not in .htaccess, though they are usually about the same configuration)

Codeigniter .htaccess to remove index.php but what about sub-directory access?

I have a successful implementation of htaccess to remove index.php in codeigniter. Which meant that I can access any controller via domain.com/controllername.
However, I realized that with this implementation I cannot access sub-directory within the server via the URL. Please advice if there is a working solution to resolve such issue.
Thank you
The htaccess which I am using now is as follows
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|update\.php|administrator\.php|assets|admin|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
<FilesMatch ".(ico|jpg|jpeg|png|gif)$">
ExpiresActive On
ExpiresDefault "access plus 1 month"
</FilesMatch>
Mark this may be the probable solution to your issue where you are unable to access the sub
folders of the system.
# if a directory or a file exists, use it directly
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php #Here you write the line which will overwrite the index.php and will move the control to your controller.
The comments in the code are itself self speaking.
For more exact answer post your exact htacess you are using.
Hope that helps you.
if your pointing out another site inside your domain aka sub-folder. Edit your .htaccess like this :
RewriteBase /domain.com/sub-folder/
or
RewriteBase /sub-folder/

Apache Rewrite URL, Works in WAMP, not in LAMP

I have a custom MVC app, where in it used IndexController naming convention, which I have built on WAMP. Today i tried it to put in to Linux (LAMP).. Strangely, it is giving error "page not found". Can anybody help. I am not good at mod rewrite,
Following is the code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?request=$1 [L,QSA]
URL is
http://hostname/mvc/incident/add
Error is The requested URL /app01/users/public_html/mvc/index.php was not found on this server.
You need to put a / before index.php and some other stuff. Look at the example I got from Wordpress's one.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Try either adding:
RewriteBase /mvc/
just under the RewriteEngine on directive, or add a leading slash to index.php:
RewriteRule ^(.*)$ /mvc/index.php?request=$1 [L,QSA]
Hi I solved this issue by using error redirecting functionality. I put following code in my .htaccess file
ErrorDocument 403 /~renjith/mvc/index.php
ErrorDocument 404 /~renjith/mvc/index.php
and in index.php file i used, $_SERVER['REQUEST_URI'] to get thr URL with query strings
I think that ./htaccess configuration is correct. I solved it simply by adding this directive to my apache2.conf file on debian.
<Directory /var/www/html/your_app_folder>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted</Directory>

Server Internal Error 500 on CakePHP 2.0

I'm using CakePHP 2.0 for my website frameworks, I located my cakephp files on server but i have some problems, named Server Internal Error 500, I don't know what i supposed to do, the other pages is working well, but some pages is encountered a 500 server internal error, I've checked the controller, view, model, and they said is no error detected, but the firebug says, the view is missing, this is my .htaccess file
public_html/cakephp/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~magang/smkn1pst/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
public_html/cakephp/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
public_html/cakephp/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~magang/smkn1pst/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
I already following steps, by adding / ex: app/webroot/ to /app/webroot/ and webroot/ to /webroot/ but still not works for me, i need to steps up to the next project, but this problem is bugging my day.
You are using mod_userdir, when using that indeed you need the RewriteBase, as mod_rewrite removes the ~ charachter
RewriteBase /~magang/smkn1pst
in all 3 .htaccess files should work, as it does for me
Currently one of your files is missing this line
This should help fix your error.
http://ask.cakephp.org/questions/view/getting_http_1_0_500_internal_server_error_in_my_cakephp_website
i am not sure please try
RewriteBase /smkn1pst/
I had a similar problem (static files were redirected properly with the correct RewriteBase in the root htaccess).
It turned out (after 4 hours of debugging .htaccess) that my FTP client had skipped the app/tmp/ directory because of a rule I added myself.
That also yielded a 500 error.

Categories