开发者

url rewriting in php htaccess

开发者 https://www.devze.com 2023-01-01 00:21 出处:网络
Hai I have 2 questions. 1) I want to create a clean url web site. My server is CGI/FastCGI. I know how this does in apache. But how I will do this in CGI server, does any one give me the details?

Hai I have 2 questions.

1) I want to create a clean url web site. My server is CGI/FastCGI. I know how this does in apache. But how I will do this in CGI server, does any one give me the details?

2) I want to create the clean url l开发者_如何学JAVAike mydomain/index.php?id=1&sort=a to

mydomain/index/id/1/sort/a Is it possible?

Does any one help me?


CGI is not a server. Apache, IIS are examples of web servers.

If you are using Apache (this is incredibly likely if using fastCGI), then using this in your .htaccess file will redirect requests from mydomain/index/id/1/sort/a to mydomain/index.php?id=1&sort=a in the background, without the user knowing:

RewriteRule ^index/id/([0-9]+)/sort/(a|d)$ /index.php?id=$1&sort=$2 [NC]

Hopefully this is self explanatory.

.htaccess is a feature of apache, for which you may need to enable AllowOverride in httpd.conf

0

精彩评论

暂无评论...
验证码 换一张
取 消