0

我想让我的所有域都重写并看起来不错。例如:

example.com/blog.php?article=the-name-of-article 成为 example.com/blog/the-name-of-article

所以我希望将 .php?article= 更改为 /

我当前的 .htaccess 文件如下所示:

Options +FollowSymLinks -MultiViews
rewriteengine on

RewriteBase /

## Hide .php extension
## To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

但所做的只是删除 .php

我一直在四处寻找,但我只想听听每个人是如何如此轻松地做到这一点的。

4

1 回答 1

1
RewriteRule ^blog/(.*)$ blog.php?article=$1 [QSA,L]
于 2013-05-29T23:01:35.527 回答