1
我希望重寫規則能夠將GET變量更改爲更好的url。在Wordpress中將GET變量更改爲url路徑
例如:
example.com?category=news到:example.com/category/news
我也希望其他得到獨處的變量。
實施例:
example.com?category=news &排序= ASC到:example.com/category/news &排序= ASC
的修改需要發生在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
我不想重定向t,我只想要改變網址。
更新1
我試圖喬恩·林的例子。它有效,但我想先添加一個/ en,並且我還希望該類別是可變的。
我試過Mod Rewrite Generator,我得到了這個結果,但它不起作用。
RewriteEngine On
RewriteRule ^category/([^/]*)$ /en/?category=$1 [L]
接下來我試圖將兩者結合起來,但我沒有更接近地找出問題所在。
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /(index\.php)?\?/en/category=$1&?([^\ ]*)
RewriteRule^/en/category/%1?%2 [L,R]
RewriteRule ^category/([^/]*)$ /en/?category=$1 [L,QSA]
# 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
如果不能的.htaccess做,我願意使用PHP。但是,它需要在Wordpress中工作。 – arrow 2014-10-28 17:40:43
沒有辦法改變瀏覽器的地址欄中的網址*沒有*重定向 – 2014-10-28 20:22:04
我的意思是說,儘管PHP所關注的網址仍然是原來的網址,但用戶看到的是更好的網址。 – arrow 2014-10-28 21:10:53