scrapy shell gets 301 redirected to url without parameters

  • Last Update :
  • Techknowledgy :

Mine was

Mozilla / 5.0(X11; Ubuntu; Linux x86_64; rv: 31.0) Gecko / 20100101 Firefox / 31.0

Now in project_name/items.py add the following line:

USER_AGENT = "whatever the user agent string was"

Suggestion : 2

Your rule are using an exact match for {REQUEST_URI} and this variable also contain query string. So try to replace {REQUEST_URI} to{URL}.,Returning an array from a method and storing it in a single variable and many ones,Special characters to mass replace string using sed command,jquery replace string where complete string matches

Mozilla / 5.0(X11; Ubuntu; Linux x86_64; rv: 31.0) Gecko / 20100101 Firefox / 31.0

USER_AGENT = "whatever the user agent string was"
            {
               path: '/',
               pathMatch: 'full',
               redirectTo: 'Employees'
            },
RewriteRule ^ (.*)\.php$ https: //www.example.com/$1 [NS,R=302,L]
<rules>
                <rule name="Redirect old url to Newb" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{Newb:{URL}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="{C:1}" appendQueryString="true" redirectType="Temporary" />
                </rule>
RewriteEngine On
RewriteCond % {
   QUERY_STRING
} != ""
#if there is a query string
RewriteCond % {
   QUERY_STRING
}! ^ p = .*#wordpress users: allow post tempalinks
RewriteCond % {
   REQUEST_URI
}! ^ /wp-admin.* #wordpress users: don't break admin
RewriteRule ^ (.*) $ / $1 ? [R = 301, L] #remove query string
RewriteCond % {
   QUERY_STRING
} ^ id = About$
RewriteRule ^ page.php / about[NC, R, L]

Suggestion : 3

You can subclass RedirectView, override get_redirect_url, and reverse the url there.,urls.py redirect with URL reversal and parameters -- is there any easier way?,How do I perform a view lookup with a pk and subsequently redirect to a url with the correct slug? (django),How Can i redirect url to another url with the .htaccess in cpanel

You can subclass RedirectView, override get_redirect_url, and reverse the url there.

class MonthRedirectView(RedirectView):
   def get_redirect_url( * args, ** kwargs):
   today = timezone.now()
return reverse(calendar, args = [today.year, today.month])

Then include your view in the URL pattern:

url(r '^$', MonthRedirectView().as_view()),

Assuming your RedirectView is in your app's urls.py:

url(r'^(?P<year>[0-9]+)/(?P<month>[1-9]|1[0-2])$', views.calendar, name='calendar'),
url(r'^$', RedirectView().as_view(url='{}/{}'.format(todays_year, todays_month)),

the url:

url(r '^$', views.redirect_to_calendar),

the redirect view:

def redirect_to_calendar(request):
   today = timezone.now()
return calendar(request, year = today.year, month = today.month)

the view we serve to the user:

def calendar(request, year = None, month = None):

   # # A bunch of server logic

return HttpResponse(template.render(context, request))