我正在尝试创建一个 .htaccess 文件,它将实现以下目标
- 创建一个干净的网址,如 www.mydomain.com/About-Us 页面 page.php?title=About Us
- 使用 URL 上传递的参数查询数据库,例如 www.mydomain.com/?search=abc 并将其拉到页面 index.php?search=abc
这是我到目前为止的代码
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^?search=([0-9]*)$ index.php?id=$1 ## e.g www.mydomain.com/?search=try
RewriteRule ^([A-Z]*)$ page.php?name=$1
## www.mydomain.com/About-Us
##ErrorDocument 404 PageNotavailabale
####Protect the system from machines with worms
RewriteRule (cmd|root)\.exe - [F,E=dontlog:1]
#### To hold and redirect css/images/js files
RewriteRule images/(.+)?$ images/$1 [NC,L]
RewriteRule css/(.+)?$ css/$1 [NC,L]
RewriteRule js/(.+)?$ js/$1 [NC,L]