問題描述
重寫問題 (Rewrite problems)
In my site i have links like that:
www.mysite.com/loja/product_info/products_id/1301
I simple want to server rewrites it internally to:
www.mysite.com/loja?slug=product_info.php&products_id=1301
Any help will be appreciated
My .htaccess :
<IfModule mod_rewrite.c>
#Options +FollowSymLinks
RewriteEngine On
RewriteRule ^loja/product_info/products_id/([0-9]+)$ http://www.mysite.com/loja?slug=product_info.php&products_id=$1 [NC,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#RewriteRule ^loja?slug=.+/([a-z_]+\.php.*)$ $1 [L]
#RewriteRule ^product_info/products_id/([0-9]+)$ loja?slug=product_info.php&products_id=$1 [QSA,L]
#RewriteCond %{QUERY_STRING} ^options\=(.*)$
#RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2%1
#RewriteRule ^slug/([^/]+)/([^/]+)/([0-9]+)/? ?slug=$1&$2=$3 [QSA,L]
#RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([0-9]+).*$ ?$1=$2&$3=$4 [L]
#RewriteRule ^slug/([^/]+)/products_id/([0-9]+)$ ?slug=$1&products_id=$2 [QSA,L]
#loja?slug=product_info.php&products_id=1308
#RewriteRule ^page/([^/]+)/([^/]+)/([0-9]+)/? /?slug=$1&$2=$3 [QSA,L]
</IfModule>
Thanks !
參考解法
方法 1:
Try this in your .htaccess before any wordpress rules.
RewriteRule ^loja/product_info/products_id/([0-9]+)$ http://www.mysite.com/loja?slug=product_info.php&products_id=$1 [NC,L]
(by user1391670、Rob)