在htaccess文件添加這些規則的文檔根目錄(其中website
文件夾中):
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+website/(?:index\.php|)\?page=([^&]+)/(&|\ |$)
RewriteRule^/website/%1/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^website/(.+)/$ /website/index.php?page=$1 [L,QSA]
或者你可以改爲把這些規則在website
文件夾,如果更有意義:
RewriteEngine On
RewriteBase /website/
RewriteCond %{THE_REQUEST} \ /+website/(?:index\.php|)\?page=([^&]+)/(&|\ |$)
RewriteRule^%1/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ index.php?page=$1 [L,QSA]
似乎工作很好,非常感謝! – mittelmania 2014-09-27 06:44:29