url rewriting in php htaccess
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
精彩评论