有没有办法让我像这样制作一种通用网址:
/News?Today
/News?Archive
/News?703
/News?654
/News?308 (and so on)
而不是:
/News?which=Today
/News?which=Archive
/News?which=703
/News?which=654
/News?which=308 (and so on)
一位朋友给了我一个以下的建议,虽然他不确定这是正确的htaccess命令:
RewriteRule /News?Today /News.php?which=Today
答案 0 :(得分:2)
您可以在站点根目录中使用此规则.htaccess:
DirectoryIndex Ena.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ Ena.php?open=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^([^=]+)$
RewriteRule ^/?$ Ena.php?open=%1 [L]
答案 1 :(得分:-1)
未经测试:
RewriteRule ^/News?(.*)$ /News.php?which=$1 [L,QSA]
整件事:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/News?(.*)$ /News.php?which=$1 [L,QSA]
</IfModule>