我在WordPress的请帮助重写URL页面的wordpress
www.xxxxx.com/asin/
创建了一个网页和我进行了一个名为模板asin.php
网址为
www.xxxxx.com/asin/?q=B0081HBX2I
是
www.xxxxx.com/asin/q/B0081HBX2I
已经尝试过的htaccess
RewriteBase /asin/
RewirteRule ^asin/q/([0-9]+)$ ?q=$1 [L]
任何帮助吗?谢谢
我在WordPress的请帮助重写URL页面的wordpress
www.xxxxx.com/asin/
创建了一个网页和我进行了一个名为模板asin.php
网址为
www.xxxxx.com/asin/?q=B0081HBX2I
是
www.xxxxx.com/asin/q/B0081HBX2I
已经尝试过的htaccess
RewriteBase /asin/
RewirteRule ^asin/q/([0-9]+)$ ?q=$1 [L]
任何帮助吗?谢谢
请试试这个:
RewriteRule ^asin/([a-zA-Z0-9_-]+)$ asin.php?q=$1
RewriteBase /asin/
RewirteRule ^asin/q/([0-9]+)$ ?q=$1 [L]
你拼写错误的重写规则在第二行。此外,在您的正则表达式,你只检查号码,请尝试:
RewriteBase /asin/
RewriteRule ^asin/q/([0-9a-zA-Z]+)$ ?q=$1 [L]
感谢您的帮助 我已经试过了,但去404没有找到页面 –
当你尝试正确的时候,你确实留下了你的'RewriteBase/asin /'行吗?我已经更新了我的回答 – Jonathon
如果您之后/asin/
一部分从开始使用RewriteBase
那么你RewriteRule
开始匹配URL。你也看到在你的URL中使用alphanum,但你的正则表达式只使用[0-9]
。
这种替换代码:
RewriteEngine On
RewriteBase /asin/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^q/([a-z0-9]+)/?$ ?q=$1 [L,NC,QSA]
感谢您的帮助 我试过了,但转到404页未找到 –
感谢您的帮助 我已经试过了,但去404页找不到 –