[英]Rewrite domain, but still use index.php
Current code to use index.php for all urls : 当前代码对所有网址使用index.php:
RewriteRule ^(.*)$ ./index.php
But for one special case, I want to make url 但是对于一种特殊情况,我想输入网址
http://domain.com/s/this_changes
to call actually http://domain.com/steps/step/this_changes
. http://domain.com/s/this_changes
实际调用http://domain.com/steps/step/this_changes
。
I tried adding : 我尝试添加:
RewriteRule ^./s/$ ./steps/step/$1
, but it gives an error 500
. RewriteRule ^./s/$ ./steps/step/$1
,但它给出错误500
。
Try this: 尝试这个:
RewriteEngine On
RewriteRule ^s/(.+)$ /steps/step/$1 [L]
Another way you could do it is to route all your URIs through index.php, and create a function for each one. 您可以执行的另一种方法是通过index.php路由所有URI,并为每个URI创建一个函数。
RewriteRule ^s/this_changes$ steps/step/this_changes
if it is that simple or 如果就这么简单或
RewriteRule ^(.*)/(.*)$ steps/$1/$2
And your specific code would work like this 您的特定代码将像这样工作
RewriteRule ^s/(.*)/?$ ./steps/step/$1
The (.*) is referenced in your $1 in the second part of your code. 代码的第二部分在$ 1中引用了(。*)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.