[英]apache url rewrite QUERY_STRING
我有一些页面,我想从localhost/wordpress/site/news?title=apple&num=1
进行修改localhost/wordpress/site/news?title=apple&num=1
到localhost/wordpress/site/news/apple/1/
这是我的.htaccess代码:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
RewriteCond %{QUERY_STRING} ^title=(.*)&num=([0-9]+)$
RewriteRule ^/wordpress/site/news$ /wordpress/site/news/%1/%2? [R=301,L]
</IfModule>
# END WordPress
为了与其他页面有所不同,更好的方法可能是使用site/news
而不是news
。 并且可以是需要一个最终的/
为localhost/wordpress/site/news/apple/1/
,因为所有这些查询页面有一些jQuery的滑块plungin,在巫继电器fragment #
为left
right
的控制,URL规则也写。 ( localhost/wordpress/site/news/apple/1/#2
)
我确定localhost/wordpress/site/news?title=apple&num=1
可以工作,但是localhost/wordpress/site/news/apple/1/
会跳到localhost/wordpress/site/
如何以正确的方式进行url重写? 谢谢。
您应该使用wordpress .htaccess,并使用dasboard-> settings-> permalinks声明永久链接结构
我可以为您编写路线,但wordpress可以做得更好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.