.htaccess重写url并删除.php [英] .htaccess rewrite url and removing .php

查看:70
本文介绍了.htaccess重写url并删除.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过htaccess文件从URL中删除.php.例如,将 home.php 更改为 home .我正在htaccess文件中使用以下重写规则.

I want to remove the .php from the url through htaccess file. for example home.php to home I'm using the following rewrite rule in htaccess file.

  RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]

,我也想重写该URL.例如

and also I want to rewrite the url. for example

/detail.php?ca=38&title=rewrite uri sample 

detail/article/38/rewrite uri sample

推荐答案

我尝试搜索整个www,然后得到一个答案.

I try search to the entire www, then I have an answer..

RewriteEngine On
Options +FollowSymLinks -MultiViews

RewriteRule    ^article/([0-9]+)/?$    detail.php?ca=$1    [NC,L]   
RewriteRule    ^article/([0-9]+)/([A-Za-z0-9-]+)/?$    detail.php?ca=$1&title=$2    [NC,L]  

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

这篇关于.htaccess重写url并删除.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆