SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast ToolBox84's Avatar
    Join Date
    May 2012
    Location
    Glendale, CA. Los Angeles.
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is there a way to write notes in htaccess file?

    Is there a way to write notes in .htaccess file like we do in html or css files? If yes how?

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,080
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Yes, start the line with a #

    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Yes. If they are just on one line, you can just put // at the start of the line to make it a comment.

    If your comment goes over multiple lines, I believe you can wrap those lines in /* */ (like PHP and CSS) but test this out rather than taking my word for it, as I'm not sure if it works in all circumstances.

    Edit:

    Beaten to it—no doubt with a better answer!

  4. #4
    SitePoint Enthusiast ToolBox84's Avatar
    Join Date
    May 2012
    Location
    Glendale, CA. Los Angeles.
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    Yes, start the line with a #

    Is this how its done # Redirect 301 /example.html http://www.domain.com/example.html

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by SESeskiz View Post
    Is this how its done # Redirect 301 /example.html http://www.domain.com/example.html
    Make sure the line starts with the # (no words before it, like you have).

    The easiest way to be sure is to test it on your htaccess file.

  6. #6
    SitePoint Enthusiast ToolBox84's Avatar
    Join Date
    May 2012
    Location
    Glendale, CA. Los Angeles.
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks i'll try now

  7. #7
    SitePoint Enthusiast ToolBox84's Avatar
    Join Date
    May 2012
    Location
    Glendale, CA. Los Angeles.
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    works great thanks

  8. #8
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,080
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    For reference, // and /* */ do NOT work in .htaccess. only #
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    For reference, // and /* */ do NOT work in .htaccess. only #
    Eek, thanks Remon. DK mentions them in his notes, so I obviously misread the purpose of them.

  10. #10
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    SES & Ralph,

    That (# anywhere on the line will render anything following it as a comment) was the best answer for a one-liner but you can comment out an entire block of mod_rewrite code using the RewriteEngine on|off directive. Obviously,
    Code:
    RewriteEngine on
    # bunch of mod_rewrite code - enabled by the 'on'
    
    RewriteEngine off
    any mod_rewrite code which needs to be disabled
    RewriteEnging on
    
    # return to mod_rewrite processing
    The only warning I can provide is that the RewriteEngine directive is specific to mod_rewrite code processing so don't use it to comment out Apache directives!

    Yes, I get too focused on mod_rewrite but this is a very useful way to comment out mod_rewrite code.

    Regards,

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

  11. #11
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dklynn View Post
    the RewriteEngine directive is specific to mod_rewrite code processing so don't use it to comment out Apache directives!
    Cool, thanks DK. Now I have to learn to distinguish between the two.


Tags for this Thread

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
  •