Results 1 to 2 of 2
  1. #1

    Apache rewrite issue makes no sense. Help?

    Hi all!!

    This one has me stumped.

    I'm trying to do a 301 redirect of some old pages to new ones.

    They work perfectly fine without the R flag, but if I add any kind of [R] or [R=301] they break.


    RewriteRule test_page.html new_page.html

    Dont work:

    RewriteRule test_page.html new_page.html [R=301]
    RewriteRule ^/test_page.html new_page.html [R=301]
    RewriteRule ^test_page.html new_page.html [R=301]
    RewriteRule test_page.html hxxp://wwwDOTdomainDOTcom/new_page.html [R=301]

    After turning on the rewrite logging, I saw what was happening:

    Without the R flag, the result is:

    [per-dir /var/www/html/] add per-dir prefix: test_page.html -> /var/www/html/new_page.html
    [per-dir /var/www/html/] strip per-dir prefix: /var/www/html/new_page.html -> new_page.html

    But, when I add the R flag:

    [per-dir /var/www/html/] add per-dir prefix: test_page.html -> /var/www/html/new_page.html
    [per-dir /var/www/html/] explicitly forcing redirect with hxxp://wwwDOTdomainD0Tcom/var/www/html/new_page.html

    Instead of stripping the prefix, Apache is inserting the doc root path in the URL. What the heck is THAT?

    Had to change it to DOTs since Im new :/
    Last edited by Ahhk; 11-17-2012 at 11:52 PM.

  2. #2
    Join Date
    Jan 2013
    Virginia Beach, Va
    For your rules with the [R=301], did you attempt those 1 at a time, or all at once in that order you have them?

    Typically you'd want to set it to [R=301,L] to indicate if that RewriteRule is triggered it knows to stop trying to process any further rules.

    This rule should work, and I've verified it on my own server:

    RewriteRule test.htm HTeaTeaP://domainDOTcom/test2.htm [R=301,L]
    Hope that helps.

    - Jacob

Similar Threads

  1. 20% Memory Used - Makes No Sense
    By uzair21 in forum Hosting Security and Technology
    Replies: 5
    Last Post: 04-09-2011, 02:14 PM
  2. Apache rewrite rule issue please help me......
    By unimaxlin in forum Web Hosting
    Replies: 6
    Last Post: 02-24-2011, 09:50 PM
  3. This makes no sense to me I cannot figure out the problem
    By lexington in forum Programming Discussion
    Replies: 19
    Last Post: 08-14-2007, 03:24 AM
  4. Apache rewrite issue
    By rhf133 in forum Programming Discussion
    Replies: 3
    Last Post: 02-18-2006, 06:45 PM
  5. Co-location makes no sense to me.
    By papaj123 in forum Colocation and Data Centers
    Replies: 79
    Last Post: 07-16-2004, 09:24 AM

Posting Permissions

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