dousi1961 2017-04-04 11:03
浏览 18

如何更改php中的文件扩展名[复制]

This question already has an answer here:

This is the problem I am going through explained below:

1) When I click on TAB say “blog” the URL shows xxxxxx/blog.php

2) When I click on a topic inside a blog say “shopping” the URL shows xxxx/shopping.php

In my first problem, I want to remove the .php extension from the URL and want it to show like this xxxxxx/blog instead of this xxxxxx/blog.php

In my second problem, I not only want to remove the .php extension from the URL but I also want the URL to show the path like this; xxxxx/blog/shopping instead of showing only this xxxx/shopping.php

<?php

include("company_profile/lib/data.config.php");

// if id exists in URL
if (isset($_GET['id']))
{
$page = (int)$_GET['id'];
}
else
{
$page = '';
}

// limit of pages shown
$limit = 5;

// if page is not empty
if($page == '')
{
$page = 1;
$start = 0;
}
else
{
$start=$limit*($page-1);
}

$query = mysqli_query($conn, "SELECT * FROM blog order by id desc LIMIT            $start, $limit");

$tot = mysqli_query($conn, "SELECT * FROM blog");
$total = mysqli_num_rows($tot);
$num_page = ceil($total/$limit);

// function of pagination that showing number of pages
function pagination($page, $num_page)
{
echo'<ul style="list-style-type:none;">';

for($i=1;$i<=$num_page;$i++)
{
if($i==$page)
{
echo'<li class="pagination-button">'.$i.'</li>';
}
else
{
// <a href="http://example.com/blog/?id='.$i.'">  this is IMPORTANT your url to blog posts
echo'<li class="pagination-button"><a href="http://localhost/soft/arif.php?    id='.$i.'">'.$i.'</a></li>';
}
}

echo'</ul>';
}


?>
</div>
  • 写回答

1条回答 默认 最新

  • dte66654 2017-04-04 12:25
    关注
    RewriteEngine  on
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
    
    评论

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接