• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Apply hash tag comments ("#") to .htaccess files

New Here ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

Does anyone have a solution to easily comment in/out lines of code in .htaccess files?

Example:

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ -

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php

Change to:

# RewriteEngine On

# RewriteBase /

# RewriteRule ^index\.php$ -

# RewriteCond %{REQUEST_FILENAME} !-f

# RewriteCond %{REQUEST_FILENAME} !-d

# RewriteRule . /index.php

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

You can do that with any editor.

https://www.google.com/search?source=hp&ei=2MUsXfyaBojt_Qbz4JbwCg&q=linux+editors&oq=linux+editors&g...

Keep in mind that if you are in a linux environment you have to open the file with Administrator privileges.  If you are in a Windows environment, you can use NotePad to make the changes.

V/r,

^ _ ^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

your choice,

search and replace (endline br start line, by a      endline # start line ) you'll still must have the very first line to handle (depending!!)

or

us a <IfDefine foo>...</IfDefine> directive block.. as foo won't be declared... all the in between instructions will be avoid... (depending on your apache settings)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

Why can't you manually add hash tags to your .htaccess code in Dreamweaver?

## THIS IS A COMMENT ##

## THIS IS A COMMENT ##

## THIS IS A COMMENT ##

## THIS IS A COMMENT ##

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Nancy+OShea  a écrit

Why can't you manually add hash tags to your .htaccess code in Dreamweaver?

I think that the OP question was to avoid to do it manually on each line step by step... so my previous answer... don't you think ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

For 6 lines of code?

Why not simply remove the code?

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

Now that Birnou mentions it, it does seem odd that someone would ask how to insert comment tags into a .htaccess file; so assuming that the OP wanted to do this programmatically instead of one-at-a-time manually makes sense.  OP was probably just supplying six lines for demo of question for brevity.

And unless 90% of the code in any given document is commented-out code and not notes for future reference, one should _never_ just 'remove the code'.  I've made that mistake several times, early on in my career, and have learned from it. 

V/r,

^ _ ^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

well, seeing the sample code shows that it is all about WP.

when trying to apply secure to WP we often have to comment uncomment part to adjust (depending on the extensions that we use)... so applying comment to block and no one line at at a time is a time saving

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

If keep multiple versions of .htaccess for various applications. 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

Correct. I'm tired of doing it manually! The above code was just shown as an example, and it doesn't always involve WordPress.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

LATEST

Why do you need to keep commenting out and changing htaccess - is it switching between local testing server and production server?

<If "%{HTTP_HOST} == 'localhost' || %{HTTP_HOST} == '127\.0\.0\.1'">

#LOCAL TESTING SERVER  STUFF HERE

</If>

<Else>

#LIVE WEBSITE STUFF HERE

</Else>

Paul-M - Community Expert

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

I think we need nmore info here - you can use various different if and conditional statements in htaccess which might be a way to acheive what you need.

Paul-M - Community Expert

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

so didn't message #2 answer your question ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines