I think I have to write it on web.config file. My server is not responding on .htaccess file. How could i convert this .htaccess to web.config file. Please help.
I am using xampp as local server where my site works completely.
But when i upload it to plesk only index page is working but all other link inside index is not working. My site is d-subidha.com Other link will show error as below.
Not Found
The requested document was not found on this server.
<?php
/**
* Front controller
*`enter code here`
* PHP version 7.0
*/
/**
* Composer
*/
require dirname(__DIR__) . '/vendor/autoload.php';
/**
* Error and Exception handling
*/
error_reporting(E_ALL);
set_error_handler('CoreError::errorHandler');
set_exception_handler('CoreError::exceptionHandler');
/**
* Sessions
*/
session_start();
/**
* Routing
*/
$router = new CoreRouter();
// Add the routes
$router->add('', ['controller' => 'Home', 'action' => 'index']);
$router->add('search', ['controller' => 'Home', 'action' => 'search']);
$router->add('login', ['controller' => 'Login', 'action' => 'new']);
$router->add('logout', ['controller' => 'Login', 'action' => 'destroy']);
$router->add('password/reset/{token:[da-f]+}', ['controller' => 'Password', 'action' => 'reset']);
$router->add('signup/activate/{token:[da-f]+}', ['controller' => 'Signup', 'action' => 'activate']);
$router->add('{controller}/{action}');
$router->dispatch($_SERVER['QUERY_STRING']);
here is my .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?_url=/$1 [QSA,L]
2
Answers
You messed up in configuring the server here:
You actually configured the routes to work in this manner:
but due to your server configuration it is not finding any path in your route so it is giving a 404. To solve this change your server rewrite rule.
Your site is working by navigating to url with a “?”. eg
Working screenshot is attached.
Set up the links like this:
https://d-subidha.com/index.php?login
It was working for me.
Or change your RewriteRules.