开发者

.htaccess url rewriting

can anybody please tell me the rewrite rule so I can make a URL like this:

http://www.mysite.com/index.php?page=directory1/page
what I'm trying to d开发者_Python百科o is remove the "index.php?page=" so i get a
"http://www.mysite.com/directory1/page"


This is how Drupal does it; it's very similar to toneplex's example, but it doesn't mess around with extension checking and it adds an extra check on favicon.ico, which many browsers automatically request; this saves an extra hit on your PHP code if you're missing favicon.ico.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]


I'm assuming you are trying to bootstrap everything via the index.php file. So try this out. Any file or directory that doesn't exist will be force through the index.php file.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜