【发布时间】:2013-12-09 23:29:52
【问题描述】:
对.htaccess 非常陌生,大部分内容并不完全理解。无论如何,目的是将/index.php?page=sample重写为sample.htm。 (或任何其他页面)
下面的脚本似乎可以部分工作。如果我键入 /sitemap.htm,它会显示该页面,但地址栏会更改为 /index.php?page=sitemap。如何将网址重写为更友好的网址,以便当我输入 /sitemap.htm 时地址保持不变,当我输入 /index.php?page=sitemap 时,它会重定向到 /sitemap.htm 但仍然有效?
抱歉,如果我听起来令人困惑。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /test/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+getreal\.co\.uk/index\.php\?page=([^&\s]+) [NC]
RewriteRule ^ %1.htm? [L,R=301]
RewriteRule ^(.+?)\.htm?$ index.php?page=$1 [L,R=301]
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite