文件夹:
htaccess:
# Load files from pages folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+pages/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^pages/)^(.*)$ /pages/$1 [L,NC]
# Default index.php
DirectoryIndex home.php
RewriteRule ^/?$ /home [L,R]
这可行,但是当我打开 localhost:1993 时,它将地址更改为 localhost:1993 / home 。我应该如何编辑htaccess以便不出现 / home ? (仅适用于 localhost:1993 )。
我的请求是:
答案 0 :(得分:0)
RewriteRule ^contact$ pages/contact.php [NC,L,QSA]
或
RewriteRule ^([a-zA-Z0-9-]*)$ pages/$1.php [NC,L,QSA]
查询版本:
RewriteRule ^([a-zA-Z0-9-]*)/(.*)$ pages/$1.php?query=$2 [NC,L,QSA]