[英]How to rewrite somedomain.com/free/single/result_id to somedomain.com/f/single/result_id
I'm having trouble getting my head around rewrite
. 我在rewrite
遇到麻烦。
I'm trying to make it so that the URL somedomain.com/f/single/1
would grab the result from somedomain.com/free/single/1
我正在尝试使URL somedomain.com/f/single/1
能够从somedomain.com/free/single/1
获取结果
I've tried the following. 我已经尝试了以下方法。
RewriteRule ^/f$ /free$1 [L]
Here is a copy of my existing .htaccess with a suggestion made by Kamil... 这是我现有的.htaccess文件的副本,其中包含Kamil的建议。
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^f/(.+)$ /free/$1 [L]
I wonder if the problem is that I am already removing index.php before the /free ? 我想知道问题是否在于我已经在/ free之前删除了index.php吗?
Can anyone help me understand what I'm doing wrong? 谁能帮助我了解我在做什么错?
You look for following rule: 您寻找以下规则:
RewriteRule ^f/(.+)$ /free/$1 [L]
The first part ^f/(.+)$
is regular expression - it matches all strings starting with /f/
and stores the rest to the $1
... then it's rewritten to /free/
and the rest stored in $1
. 第一部分^f/(.+)$
是正则表达式 -它匹配所有以/f/
开头的字符串,并将其余的字符串存储到$1
...然后将其重写为/free/
并将其余的字符串存储在$1
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.