.htaccess替换问号

时间:2015-02-03 17:01:33

标签: php .htaccess

我正在尝试用斜杠替换问号。 lockalhost / work / gallery?album = pirano => lockalhost /工作/画廊/钢琴 当我去lockalhost / work / gallery / piano时,我收到500内部服务器错误。如何解决这个问题 另外如何删除.php扩展表单文件。我正在使用这个

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

但有没有更好的方法呢?

1 个答案:

答案 0 :(得分:1)

也许是这样的?

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+work/gallery\?album=([^&\ ]+)
RewriteRule ^ /work/gallery/%1? [L,R]

RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\.php
RewriteRUle ^ /%1 [L,R]

RewriteRule ^work/gallery/(.*)$ /work/gallery?album=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)$ /$1.php [NC,L]