开发者

"Flat links" with Apache

I'm attempting to convert URLs with GET variables from something like

http://domain.com/?username=john

to

http://domain.com/john

using following the articles here and here.

Using the example in the first article (with a slight modification) - RewriteRule .* index.php - I have gotten that to work. The first problem is, I still want to be able to access the other files in the sa开发者_StackOverflowme directory. So the closest I've gotten so far is RewriteRule index\.php/(.+) index.php?username=$1, which is still not ideal because I don't want the filename in the URL, but there's another problem. index.php is set as the DirectoryIndex, and I have no idea how to match that.

I'm still very much a beginner at configuring Apache, so any help is greatly appreciated.


Try something like that

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !\.php$
RewriteCond %{QUERY_STRING} \buser=\w+
RewriteRule .* user.php [L]

put instead of user.php the name of your script.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜