如何结合2 .htaccess重写

时间:2018-09-21 20:38:04

标签: php .htaccess

我的.htaccess文件中有2种不同的重写,需要合并为1。

第一个将所有请求重定向到网站的kill $PID版本。

<package id="Unity" version="5.8.11" targetFramework="net471" />

第二个获取所有发布数据并分配给变量。

static class Program
{
    [STAThread]
    static void Main()
    {            
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        using (var container = UnityConfig.BuildUnityContainer())
        {
            var presenter = container.Resolve<IForm1Presenter>();

            Application.Run((Form)presenter.View);
        }
    }
}

public static class UnityConfig
{
    public static IUnityContainer BuildUnityContainer()
    {
        var container = new UnityContainer();

        container
            .RegisterType<IForm1, Form1>(new PerResolveLifetimeManager())
            .RegisterType<IForm2, Form2>(new PerResolveLifetimeManager())
            .RegisterType<IForm1Presenter, Form1Presenter>(new TransientLifetimeManager())
            .RegisterType<IForm2Presenter, Form2Presenter>(new TransientLifetimeManager());

        return container;
    }
}

public interface IForm1
{
    void Show();
    event EventHandler ButtonClick;
}


public interface IForm1Presenter
{
    IForm1 View { get; }
}
    public class Form1Presenter : IForm1Presenter
{
    public Form1Presenter(IForm1 view, IForm2Presenter form2Presenter)
    {
        view.ButtonClick += (s, e) => form2Presenter.ShowView();
        View = view;
    }

    public IForm1 View { get; }
}

    public IForm1 View { get; }


}

public interface IForm2
{
    void Show();
}

public interface IForm2Presenter
{
    void ShowView();
}

public class Form2Presenter : IForm2Presenter
{
    private readonly IForm2 _view;

    public Form2Presenter(IForm2 view) => _view = view;

    public void ShowView() => _view.Show();
}

如何将两者结合使用?

谢谢

1 个答案:

答案 0 :(得分:1)

您可以在网站中使用以下组合规则:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]