htaccess重写除两个以外的所有页面

时间:2015-04-14 16:34:39

标签: .htaccess

我在htaccess文件中有这段代码:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} = 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^login/?$ login.php
RewriteRule ^logout/?$ logout.php

RewriteRule ^([\w/-]+)/?$ index.php?id=$1 [L,QSA]

所以我想重写所有index.php?id=LINK-HERE

的链接

排除/ login和/ logout应该重写为login.php和logout.php,但它们不起作用。他们似乎正在使用?id = ...

1 个答案:

答案 0 :(得分:1)

你可以这样做

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

# remove those 2 following lines when running on localhost
RewriteCond %{HTTP_HOST} !^admin\.integra-uk\.net$ [NC]
RewriteRule ^ - [L]

RewriteRule ^login/?$ login.php [L]
RewriteRule ^logout/?$ logout.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w/-]+)/?$ index.php?id=$1 [L,QSA]