SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: WordPress Redirect

  1. #1
    SitePoint Zealot w1nk5's Avatar
    Join Date
    Aug 2009
    Location
    Ontario, Canada
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WordPress Redirect

    Please help me understand why my rules highlighted in red don't work.

    URL
    www . markrequenaphotography . ca/wedding-photography/?serv=Professional%20Wedding%20Photography&loc=Kent%20Bridge

    .htaccess
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{QUERY_STRING} ^serv=(.*?)&loc=([^/]*)$ [NC]
    RewriteRule (.*) http://www.markrequenaphotography.ca/%1/%2/? [R=301]
    
    RewriteCond %{HTTP_HOST} ^markrequena\.ca$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.markrequena\.ca$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^markrequenaphotography\.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^markrequena\.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.markrequena\.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^requena\.co\.uk$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.requena\.co\.uk$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.markrequenaphotography\.com$ [NC]
    RewriteRule (.*) http://www.markrequenaphotography.ca [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    Output
    www . markrequenaphotography . ca/wedding-photography/?serv=Professional%20Wedding%20Photography&loc=Kent%20Bridge

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,314
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    From my reading of what you've shown, the resultant URI should have been Professional%20Wedding%20Photography/loc=Kent%20Bridge which should not exist as a file, thus, /index.phpl

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Guru bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    730
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    @w1nk5

    Notice the "last" flag, highlighted in red.

    RewriteRule (.*) http://www.markrequenaphotography.ca/%1/%2/? [R=301,L]

    Without that, all the other rewrite rules are still applied, in particular the last rewrite rule, which rewrites to index.php.
    "Folks who know what they're doing make complexity seem simple."

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,314
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    w1nk5,

    The Last flag simply tells Apache to execute the redirection and start over with mod_rewrite processing with the new {REQUEST_URI} string which will then should bypass the first two RewriteRule blocks and WP's greedy code will then redirect the non-file and non-directory requests to index.php. In other words, the Last flag has nothing to do with the end result of index.php because mod_rewrite will continue its processing until there are no redirections.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •