简体   繁体   English

基本 .htaccess mod_rewrite 帮助

[英]Help with basic .htaccess mod_rewrite

I am currently interpreting sub-domain wild-cards with php and i would like to handle them with .htaccess, user profiles will be accessed at http://username.mysite.com/ (or for some people http://www.username.mysite.com/ ) which should use /main.php?action=profile I am currently interpreting sub-domain wild-cards with php and i would like to handle them with .htaccess, user profiles will be accessed at http://username.mysite.com/ (or for some people http://www.username .mysite.com/ )应该使用 /main.php?action=profile

The hardest part of this is making /error/i+am+a+test+message or /files/iamatestfile.jpg go to &error=i+am+a+test+message or &files=iamatestfile.jpg最难的部分是制作 /error/i+am+a+test+message 或 /files/iamatestfile.jpg go 到 &error=i+am+a+test+message 或 &files=iamatestfile.jpg

Thanks for any and all help!感谢您的任何帮助!

Try:尝试:

 RewriteRule ^error/(.*) index.php?error=$1 [L]
 RewriteRule ^file/(.*) index.php?file=$1 [L]

... for the last two. ...对于最后两个。

Try this:尝试这个:

# stop rewriting for the host names example.com and www.example.com
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^ - [L]

RewriteRule ^error/(.*) index.php?error=$1 [L]
RewriteRule ^file/(.*) index.php?file=$1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM