简体   繁体   English

我如何设置htaccess以允许发生更改?

[英]How do i setup htaccess to allow changes to occur?

below is the rewrite rule: 以下是重写规则:

RewriteEngine On

RewriteRule ^search/$ search/searchPage.php [L,NC]

the .htacess file is located at the root of the website .htacess文件位于网站的根目录

problem is that it does not exactly take me to searchPage.php when I just type domain.com/search/, it just takes me to a 403 error page (note there is no index.php page here). 问题是,当我只键入domain.com/search/时,并不会完全把我带到searchPage.php,它只是带我到403错误页面(请注意,这里没有index.php页面)。

This is uploaded in amazon elastic beanstalk 这是在亚马逊弹性豆茎中上传的

you are basically thinking of it backwards, what you need to do is call the full url and rewrite it to the real one. 您基本上是在向后思考,您需要做的就是调用完整网址,并将其重写为真实网址。

like this, 像这样,

  RewriteRule ^search/category/(.+)/ domain.com/search/searchPage.php?crs_category=$1 [L]

and then you would use this as your url http://domain.com/search/category/business/ and rewrite ( not redirect ) it to where it is mapped. 然后将其用作您的网址http://domain.com/search/category/business/并将其重写(而不是重定向)到映射位置。 The url in the browser would stay the same. 浏览器中的网址将保持不变。

I am not sure 100% of the .htaccess off the top of my head but that is the method you would use. 我不确定100%的.htaccess都在我的头顶上,但这是您将使用的方法。

Make sense? 说得通?

The (.+) bit is a capture group and would capture the category and the $1 is where that is output as it is the first capture group. (。+)位是捕获组,将捕获类别,而$ 1是输出的位置,因为它是第一个捕获组。 Some further reading that would help is how to use regular expressions. 进一步的阅读将对如何使用正则表达式有所帮助。

As I mentioned a router in the comments, the issue with this method is you have to map each one by hand, which is ok for one or two but can get real ugly real fast. 正如我在评论中提到的路由器一样,此方法的问题是您必须手动映射每个路由器,这对于一两个路由器是可行的,但可以很快地实现真正的丑陋。

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

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