[英]Numeric value in .htaccess RewriteRule
I've searched a lot, but didn't find anything. 我已经搜索了很多,但没有找到任何东西。
I am using codeigniter. 我正在使用codeigniter。 my current url is:
我当前的网址是:
base_url/content_controller/content_download/download_id
but, I need to do it: 但是,我需要这样做:
base_url/download_id
as download id is numeric, my .htaccess doesn't work. 由于下载ID是数字,因此我的.htaccess无法正常工作。
RewriteRule ^download/content/2$ 2 [L]
Please tell me how to solve that and if there is any way to do it without .htaccess. 请告诉我如何解决该问题,以及是否有没有.htaccess的方法。
Do you mean something like this? 你的意思是这样吗?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ /download/content/$1 [L]
So if you request http://example.com/123
, the URI will be rewritten to /download/content/123
. 因此,如果您请求
http://example.com/123
,则URI将被重写为/download/content/123
。
Thanks Jon, I tried several times but multiple rule conflicts. 谢谢乔恩,我尝试了几次,但是有多个规则冲突。 So I do it in another way.
所以我用另一种方式做。 when I hit the URL http://www.example.com/2/ it shows Not Found.
当我点击URL http://www.example.com/2/时 ,显示未找到。 So, I use 404 controller to handle the numeric value.
因此,我使用404控制器来处理数字值。 Finally I have done it.
终于我做到了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.