Nette framework Url not working on localhost - php

The PHP Nette framework, Url is not working on localhost. On the live server it is working fine but when I installed it on localhost from the latest backup from hosting server it does not work.
My .htaccess file is as:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ /www/$1 [L,NE]
</IfModule>
My Localhost URL on Wamp which the home page is working properly
http://localhost/ongoingclients/www/www/
But other urls are not working.

what does it mean that it is not working? It shows 404 from apache?
try to check that
mod_rewrite in apache is enabled
AllowOverride in apache vhost settings is set to All

The above issue is resolved by .htaccess of rule RewriteBase
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ongoingclients/www/www/
# prevents files starting with dot to be viewed by browser
RewriteRule /\.|^\. - [F]
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>
Got success, thank you.

Related

Apache2 Module Rewrite it is not working as it should

I created an MVC system in PHP and use the Apache Rewrite module to protect some folders and compose URL's.
I created the base on my development machine that I use Xampp and I even used the same system on an online server (client) and everything works fine.
But I want to have this same MVC system on the server that we set up in the company where I work for other developers to use it, but this server is not working properly.
On the server giving this problem, I have installed Ubuntu 20.04 (Desktop), Apache 2, PHP 7.4.13 and MySQL. I have already enabled the Rewrite module.
And I'm using the same .htaccess that I'm using both on my machine (Windows) and on the server that is online (public webserver) Linux.
Below the .htaccess files I'm using
That first .htaccess file I use to always redirect the client into the public folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
This second is inside the public folder and is to compose the URL
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /criate/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
The latter is inside the App folder and I use them to not have access to that folder
Options -Indexes
My Apache default.conf file
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow, deny
allow from all
Require all granted
</Directory>
But what is happening, when accessing the project url, let's assume it is: https://api.aplication.com
Works perfectly well, takes me to the application home with all right. But when I click the login button, for example. Give me the following error.
Not Found
The request URL was not found on this server
But there is, because I made a copy of the project that is working both on Windows and on the online server that is Linux too.
What configuration do I have to see and analyze to resolve this issue?
In phpinfo it says what module is active. Thanks
I already found what I was doing wrong in the .htaccess files, follow what I changed, that in all .htaccess files.
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
Options -Multiviews
RewriteEngine On
RewriteBase /criate/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
It was just removing the conditions that check if the module is active or not, I will study further to find out how to do these conditions in LINUX.

Phalcon framework displays index of page instead of application

I wanted to use learn phalcon so i tried installing it on ubuntu. I did everything like in tutorial and i can see phalcon in phpinfo(). I made sample project like in tutorial with following htaccess files but all I can see when typing localhost/tutorial is index of /tutorial instead of Hello! message
#/tutorial/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ((?s).*) public/$1 [L]
</IfModule>
#/tutorial/public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
Try removing the <br> tags from your .htaccess files. If the previous doesn't work check your apache configs for the localhost, maybe it doesn't AllowOverride.
Also you can use the steps from here to create a virtual host on apache with it's document root set to the path of tutorial folder.
Everytime you change the configs of apache, remember to do a reload or a restart of the apache service.

htaccess stopped working after moving website to subdomain

So, I moved the website.com to subdomain.website.com. The .htaccess file is located in the website.com/subdomain/ folder, it should work but it's not working.
Error message: The requested URL /title-123 was not found on this server.
Basically what it does is translates the website.com/product.php?id=123&title=hello to website.com/hello-123
The error is produced when trying to access subdomain.website.com/title-123
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/product\.php\?id=([0-9]+)&title=([^\s&]+)\s [NC]
RewriteRule ^ %2-%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+?)-([0-9]+)$ product.php?id=$2&title=$1 [L]
</IfModule>
Anyone knows how to fix this? Thanks!
After a lot of research and debugging of apache conf files and receiving expert's assistance i managed to fix it removing completely the .htaccess file and adding the rewrite rules in the apache VirtualHost directly.

Routes works on localhost but not on production server

I have a fresh installation of Laravel. It works perfectly fine on my local machine. But on the server the routes doesn't work correctly.
Here's how the URL looks like on my localhost:
localhost/articles/14
But when I try the same URL on my production server it doesn't work. But it does work if I type the URL like this:
mydomain.com/index.php/articles/14
So, with the index.php in between it works fine. And the index route works without a problem. So it seems like some kind of redirect issue.
Here's how my .htaccess file looks like:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I tried adding RewriteBase /mypath/ to the .htaccess without luck.
I have searched on Google and tried some suggestion without luck.
Check if mod_rewrite is enabled on your server.
Also, .htaccess may be disabled on your server for security reasons.
Try putting your mod_rewrite on your <VirtualHost> or <Directory> section.

CakePHP application cannot start in localhost

I'm trying to get a CakePHP application to work. I use xampp and put my application files in /xampp/htdocs. For .htaccess configuration I refer to http://book.cakephp.org/1.2/view/37/Apache-and-mod_rewrite-and-htaccess . After that I'm trying to run my application, but I've got this message in browser.
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
All my other applications in which I have not used the CakePHP, runs well on localhost, without any errors. I think the problem connected with .htaccess. Any suggestions ?
EDITED
My .htaccess files
**/xampp/htdocs/app/webroot/.htaccess**
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
**/xampp/htdocs/app/.htaccess**
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
**/xampp/htdocs/.htaccess**
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I think your .htaccess files look correct. You might need to tell Apache where the webroot of your app is. Try adding a vhost entry in your Apache configuration
inside \xampp\apache\conf\extra\httpd-vhosts.conf
try adding something like:
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:\xampp\htdocs\app\webroot <-(use the actual path here)
</VirtualHost>
The you should then be able to access the CackPHP app by visiting http://localhost
Be sure to remove any other VirtualHost blocks that might conflict, although if you are working with a fresh copy of XAMPP everything in this file will be commented out.
Don't forget to restart Apache for the change to take effect.

Categories