【发布时间】:2015-06-11 12:53:49
【问题描述】:
我目前有一个我重写的 htaccess 文件 domain.com/index.php?page=home 到 domain.com/home
我的整个 htaccess 看起来像这样:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]
我正在尝试做的也是从 url 获取 &id= 所以 index.php?page=home&id=5 将被重写为 /home/5.
我遇到的另一个问题是我无法打开其他目录中的文件,例如图像目录。当我打开图像目录时,我得到了我为该站点设置的 404 页面,因为它不是一个页面,它正在尝试将 images/imagefile.jpg 作为一个页面读取。
【问题讨论】:
标签: .htaccess mod-rewrite