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
Copy link to clipboard
Copied
You can do that with any editor.
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,
^ _ ^
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)
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 ##
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 ?
Copy link to clipboard
Copied
For 6 lines of code?
Why not simply remove the code?
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,
^ _ ^
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
Copy link to clipboard
Copied
If keep multiple versions of .htaccess for various applications.
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.
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>
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.
Copy link to clipboard
Copied
so didn't message #2 answer your question ?