Highlighted

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

New Here ,
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

364

Likes

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

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

New Here ,
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

365

Likes

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
Jul 15, 2019 0
LEGEND ,
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,

^ _ ^

Likes

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
Reply
Loading...
Jul 15, 2019 1
Adobe Community Professional ,
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)

Likes

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
Reply
Loading...
Jul 15, 2019 0
Adobe Community Professional ,
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, ACP
Alt-Web Design & Publishing

Likes

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
Reply
Loading...
Jul 15, 2019 0
Adobe Community Professional ,
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 ?

Likes

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
Reply
Loading...
Jul 15, 2019 0
Adobe Community Professional ,
Jul 15, 2019

Copy link to clipboard

Copied

For 6 lines of code?

Why not simply remove the code?

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

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
Reply
Loading...
Jul 15, 2019 0
LEGEND ,
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,

^ _ ^

Likes

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
Reply
Loading...
Jul 15, 2019 1
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Jul 15, 2019 0
Adobe Community Professional ,
Jul 15, 2019

Copy link to clipboard

Copied

If keep multiple versions of .htaccess for various applications. 

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

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
Reply
Loading...
Jul 15, 2019 0
New Here ,
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.

Likes

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
Reply
Loading...
Jul 16, 2019 0
Paul-M LATEST
Adobe Community Professional ,
Jul 17, 2019

Copy link to clipboard

Copied

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, ACP

Likes

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
Reply
Loading...
Jul 17, 2019 1
Adobe Community Professional ,
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, ACP

Likes

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
Reply
Loading...
Jul 15, 2019 0
Adobe Community Professional ,
Jul 16, 2019

Copy link to clipboard

Copied

so didn't message #2 answer your question ?

Likes

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
Reply
Loading...
Jul 16, 2019 0