简体   繁体   中英

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

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).

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. 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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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