問題描述
用 .htaccess 重寫基於日期的 URL:s - 解決方案? (Rewriting date-based URL:s with .htaccess - solution?)
I've been able to set up proper permalink redirections in Wordpress by entering /%category%/%postname%/
and using the below shown snippet as my .htacccess file. - Working great!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
However when trying to access links to archived posts, such as "December 2010" (shown in the sidebar), I get to this page: http://localhost/subfolder/2010/10/
How can I instead rewrite all date-based requests to the following page? http://localhost/subfolder/archive/2010/10/
Thanks
參考解法
方法 1:
ad this prior to your last rule:
RewriteCond %{REQUEST_URI} !subfolder/\d{4}/\d{2}
then add a new rule e.g.
RewriteRule subfolder/(\d{4})/\d{2}/) archive/$1 [L]
(by Industrial、covener)