HTAccess URL 重写会影响 GET 变量


HTAccess URL Rewrite affect GET variables

我们正在使用wordpress,我们在.htaccess中有以下内容:

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index'.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress

我们有一个像 http://subdomain.example.com/select-a-card/?q=fuel 这样的 URL,我们想重写它,让它变成类似 http://subdomain.example.com/fuel-card/

我需要向 htaccess 添加什么才能执行此操作?此外,这是否会影响使用 GET 变量的查询运行?

没什么,只需阅读WordPress手册并编辑您的设置即可。 结帐 http://codex.wordpress.org/Using_Permalinks

---编辑

这是可以做到的,但前提是你有某种想要重写的URL的标准标记。即。如果您只想重写选择卡片的 URL,或者仅使用 http://site.com/uri/?q=something 等语法重写 URL。但是,如果网址的语法差异太大,您将不得不添加大量重写。

在这种特定情况下,这样的事情应该有效:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index'.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # add your specifics below:
    RewriteRule ^/select-a-card/'?q=(.*) $1-card/
    RewriteRule . /index.php [L]
</IfModule>