如何在django站点框架中使用单站点for www和root

时间:2017-02-28 01:39:21

标签: python django .htaccess subdomain django-sites

我目前只有一个网站,但我想扩展到几个网站,以便在django中使用。

我目前在我的django_sites表中必须有两个条目用于我的单个网站:

@for ($i = 1; $i < $package->package_for + 1; $i++)
<div class="container information">

    <div class="row">

        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading"><h3>Guest {{ $i }}</h3></div>
                <div class="panel-body">






                    <form class="form-horizontal" action="{{ route('information',  ['id' => $package->id]) }}" role="form" method="POST">


                     <div class="col-md-9 col-md-offset-2 fullname">
                        <div class="gender">  
                        <label> &nbsp</label>
                        <select type="text" id="gender" class="form-control col-md-1" name="gender" required>
                                                <option value="1">Mr</option>
                                                <option value="2">Mrs</option>
                                           </select>
                        </div>

                        <div class="form-group{{ $errors->has('firstname') ? ' has-error' : '' }}">
                                <label> First Name</label>
                                <input id="firstname" placeholder="First Name" type="text" class="form-control" name="firstname"  required>



                                @if ($errors->has('firstname'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('firstname') }}</strong>
                                    </span>
                                @endif
                          </div>
                        <div class="form-group{{ $errors->has('lastname') ? ' has-error' : '' }}">
                                <label> First Name</label>
                                <input id="lastname" placeholder="Last Name" type="text" class="form-control" name="lastname"  required>



                                @if ($errors->has('lastname'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('lastname') }}</strong>
                                    </span>
                                @endif
                          </div>
                        </div>

                        <div class="form-group{{ $errors->has('contact_number') ? ' has-error' : '' }}">
                            <label for="contact_number" class="col-md-4 control-label">&nbsp</label>

                            <div class="col-md-6">
                              <label>Contact Number</label>
                                <input id="contact_number_number" placeholder="Contact Number" type="contact_number" class="form-control" name="contact_number" required>

                                @if ($errors->has('contact_number'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('contact_number') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('age') ? ' has-error' : '' }}">
                            <label for="age" class="col-md-4 control-label">&nbsp</label>

                            <div class="col-md-6">
                              <label>Age</label>
                                <select type="text" id="age" class="form-control col-md-1" name="age" required>
                                @for ($b = 1; $b < 50; $b++)
                                <option value="$i">{!! $b !!}</option>

                              @endfor
                                           </select>

                                @if ($errors->has('age'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('age') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('address') ? ' has-error' : '' }}">
                            <label for="address" class="col-md-4 control-label">&nbsp</label>

                            <div class="col-md-6">
                              <label>Address</label>
                                <input id="address" placeholder="Address" type="address" class="form-control" name="address" value="{{ old('address') }}" required>

                                @if ($errors->has('address'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('address') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                </div>
            </div>
        </div>
    </div>
</div>
@endfor
 <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary" href="{{ route('package.addToCart', ['id' => $package->id]) }}">
                                        Book Package
                                </button>

                                {{ csrf_field() }}
                            </div>
                        </div>
</form>

现在我想拥有多个站点,每个子域有多个条目是不可行的,因为我想创建与这些站点相关联的对象的多对多关系。

如何为每个网站使用单个www和根域而不是两个?

1 个答案:

答案 0 :(得分:0)

我在httpd和ssl.conf

中的apache级别处理了这个问题

我在这里按照这个答案apache redirect from non www to www