.htaccess rewrite url and removing .php

2019-08-10 19:49发布

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]

and also I want to rewrite the url. for example

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

to

detail/article/38/rewrite uri sample

2条回答
Animai°情兽
2楼-- · 2019-08-10 20:18

Use

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

For GoDaddy

Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-08-10 20:41

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]
查看更多
登录 后发表回答