duanmao1872 2013-05-06 22:48
浏览 26
已采纳

htaccess为mvc框架允许www

I have been researching htaccess and learning quite a bit about it, but I'm still stuck on a very specific requirement we have. Actually there are 2 requirements, but one of them is critical while the other one is a "would be very nice."

Question 1: What is the best way to write my htaccess file for an MLM site written on MVC framework that would allow users to type www.mlmsiteaddress.org/aff/affiliatename when the site does not accept www?

Background: This software allows inserting new members, then provides that new member with a URL for which their affiliate identifier, email, phone number, address, etc show up on the banner and underneath which is a "squeeze page," or very simple opt-in form which brings in new leads to the company and other things that happen after this form submits don't have any bearing on this question.

Problem: When users click a link, or type in manually, the URL www.mlmsiteaddres.org/aff/affiliatename, it does not display the affiliate banner info. Instead, it shows just the corporate banner, which is the default affiliate in case the user had attempted to navigate to an inactive affiliate's site. For some reason this wasn't an issue before but has recently become an issue, shortly after I cleaned up a BLACOLE/JS virus off the site. From what I can ascertain, the htaccess file we are using now is identical to how it came to us from the software vendor.

Normal Behavior: Previously, the www portion of the URL was being simply ignored, and the site was loading http://mlmsiteaddress.org in the url for each affiliate site. So, even though the affiliate banner information would show up, the affiliate name would not populate in the URL. Which brings me to...

Question 2: How can I force the URL to display the affiliate username in the banner when on an affiliate page using htaccess?

Question 3: Is htaccess the only way to do these things (assuming both of these are possible)? I have some basic working knowledge of it but am no expert, though I'll have a far richer understanding once I solve this problem!

Here is the htaccess that is currently being used (which came with the mlm software "out of the box" so to speak).

<Files ~ "serial.txt$">
  Order allow,deny
  Deny from all
</Files>

RewriteEngine On

RewriteRule ^aff/(.*)$ /index.php/aff/?aff=$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [R=301,NC]
  • 写回答

1条回答 默认 最新

  • dongpin6941 2013-05-07 00:24
    关注

    If I understood correctly, connecting to http://www.mlmsiteaddress.org doesn't work but http://mlmsiteaddress.org does. In that case, you can force a redirection if the site isn't accessed via http://mlmsiteaddress.org (using www, or any other subdomain):

    <Files ~ "serial.txt$">
      Order allow,deny
      Deny from all
    </Files>
    
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^mlmsiteaddress\.org$ [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://mlmsiteaddress.org/$1 [L,R]
    
    RewriteRule ^aff/(.*)$ /index.php/aff/?aff=$1 [R,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [R=301,NC]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c