繁体   English   中英

我怎样才能正确地重写网址?

[英]How could I rewrite urls properly?

I have URLs like http://url.com/top_admin/order.php?do=view&oid=124 and I need to rewrite it to http://url.com/top_admin/order/view/124 , where top_admin is a包含我的脚本的文件夹。 这是我的代码:

Options +FollowSymLinks
RewriteEngine on                                          
RewriteRule ^order/(.*)/([0-9]+) order.php?do=$1&oid=$2 [L] 

但它不起作用。

使用您显示的示例/尝试,请尝试以下操作。 请确保在测试您的 URL 之前清除您的浏览器缓存。

Options +FollowSymLinks -MultiViews
RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/(top_admin/order)\.php\?do=([^&]*)&oid=(\d+)\s [NC]
##Rule for external rewrite with 301.
RewriteRule ^ /%1/%2/%3? [R=301,L]
##Rule for internal rewrite to .php file.
RewriteRule ^([^/]*)/([^/]*)/(.*)/?$ $1.php?do=$2&oid=$3 [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM