Answer the question
In order to leave comments, you need to log in
How to return .php at the end of page address?
Hello!
Please tell me how to return the file extension at the end of the address.
Site with one entry point.
Now it removes the file extension in the address bar.
The index file looks like this
<?
$params = array();
$query_string = str_replace("page=","",trim($_SERVER['QUERY_STRING']));
$query_string = urldecode($query_string);
$query_params = explode("/",$query_string);
foreach ($query_params as $query_param)
if ($query_param != "")
$params[] = mysql_escape_string($query_param);
?>
<?
if (count($params) == 0) $params[0] = "main";
require_once file_exists('modules/' . $params[0] . '.php')
? 'modules/' . $params[0] . '.php' : 'modules/404.php';
?>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
AddDefaultCharset utf-8
AddType 'text/html; charset=utf-8' .html .htm .shtml
AddHandler application/x-httpd-php .html .htm .js
Answer the question
In order to leave comments, you need to log in
Here:
Send any request as a parameter.
Remove:RewriteRule ^(.*)$ index.php?page=$1
RewriteEngine On #включить mod_rewrite
RewriteBase / #базовый url
RewriteCond %{REQUEST_FILENAME} !-f #все <b>существующие</b> файлы не будут обрабатываться регуляркой
RewriteCond %{REQUEST_FILENAME} !-d #все <b>существующие</b> папки не будут обрабатываться регуляркой
RewriteRule ^(.*)$ index.php?page=$1 [L] #перенаправляем то, что подходит под регулярку в виде GET-параметра
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question