redirect all air requests to index.php and take the value passed by the URL

Asked

Viewed 56 times

1

I need to redirect all requests to index.php so that you can insert the . php file corresponding to the url into the body. Example when accessing the www.dominio.com.br/forgot password click on the index the page forgot password.php. In the index there are <!doctype html> tags, all css, and all js. In the body tag I upload the .php. Simliar files to a spa. I created the htacess file as below

 RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA]


<!doctype html>
<html lang="pt-BR">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Plus-Sese-Br</title>

    <!-- Bootstrap core CSS -->
    <link href="http://localhost/app/css/bootstrap.min.css" rel="stylesheet">   
    <link href="http://localhost/app/vendor/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<body>
    
    
        
<?php 
$url = (isset($_GET['url'])) ? $_GET['url']:'login.php';
$url = array_filter(explode('/',$url));
$file = $url[0].'.php';
if(is_file($file)){
    include_once $file;
}else{
    include_once 'login.php';
}   

?>
        
        
    
<script type="text/javascript" src="http://localhost/plus-outbound/js/jquery-3.5.1.min.js"></script><script type="text/javascript" src="http://localhost/plus-outbound/js/bootstrap.min.js"></script>
</body>

</html>

if the file passed in the url does not exist is redirected to login. If the file in the url does not exist it is working. The problem is when there is the url / file is not clicking between the body tag as the example. I am using url absulta at all but when the url passed there loads the file only this file without body css and js.

  • Looks like you missed closing the <head> tag before the <body>, isn’t that right? Or by posting you forgot the tag?

  • it was only in the post that I forgot

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.