dump

WordPress Plugin: WP htaccess Control

Ler este artigo em Português

This plugin comes as a solution for two problems I was facing.

First, wanting to have custom rules written on the same htaccess file WordPress uses, even though respecting the tags # BEGIN WordPress and # END WordPress and writing my stuff before them, WordPress just kept on rewriting them, sometimes removing them completely, others just corrupting the file and making the whole site inaccessible.

Then, the Custom Author Permalink plugin was in urgent need of some re-write as it was doing it the wrong way really, wasting resources and deactivating very disgracefully.

So I merged the two points in one and came up with this WordPress plugin (which I’m already running as you’ll see below). The interface isn’t really in it’s final stage but the functionalities are there.

Releasing it as WP htaccess Control, it provides two functionalities:

  • Establish redirection pairs to be written into your htaccess file;
  • Customization of the Author Permalink Structure (or ‘base’), in a much better way than the Custom Author Permalink did.

The (current) admin page:

WP-htaControl

And the resulting .htaccess file:

WP-htaControl-htaccess

The installation is simple as usual, activate it then access the page under Settings to create redirection pairs or customizing the Author Permalink Base (optional).

The plugin is in it’s first stage, and although it is fully operational I soon shall update it an with improved interface (CSS e JS).

As always, feedback is appreciated.

Update:

WP htaccess Control is now hosted by the official WordPress plugin directory, where you’ll always find its latest version.

The admin interface as of version 1.1:

Wp htaccess Control v.1.1

33 comentários a WordPress Plugin: WP htaccess Control

  1. mattcav no dia 2 de Jul de 2009 às 11:40

    hi,

    i’ve found a problem with this plugin and my wordpress installation.
    the problem it’s about .htaccess and wp permalink core. when i enable WP htaccess Control, all my permalink give always homepage. the url changes, but page don’t load.

    check this discussion on wp support forum to know more:
    http://wordpress.org/support/topic/215237?replies=7#post-1123569

    if you want, you can write me and ask all you want know about.

    MC

    Não falo português mas eu entendo e qualquer um pode fazer a tradução das minhas respostas

    • dardna no dia 4 de Jul de 2009 às 2:55

      hey,
      thanks for the feedback.

      I went through the thread you pointed me and nothing that could help your situation comes to my mind right now. One thing you can have for sure: the Author Permalink part has nothing to do with the htaccess file or the httpd.conf; it is a rewrite of the WP internal permalink rules.

      I can not promise a quick solution but will sure look into that, I’ll be writing you an email when I get home.

      Also (could it be a plugin conflict?!), have you tried using ONLY WP htaccess Control, in a vanilla WP installation? And then, what other plugins are you using?

    • dardna no dia 6 de Jul de 2009 às 1:36

      (e-mail sent)

  2. konisto no dia 24 de Ago de 2009 às 1:16

    Hi,

    I tried your plugin but unfortunately it did not work. I’m using the “WP No Category Base” plugin to show my categories without a base before it and I believe that this is not compatible with your plugin…

    Feel free to write me for more info.

    Até logo!

    Philipp

  3. Philipp no dia 20 de Out de 2009 às 23:56

    Hi,

    I use your plugin and like it very much. I had problems at first but no it works fine…

    One issue I can’t seem to solve is that some rules don’t seem to work.

    I have a page at /suchen that returns my search results. now I would like to have a rule that says /suchen/search-word should be /suchen?q=search-word.

    I’m using ^suchen/([^/]+)/?$ to filter it, but it just doesn’t work. All I get is an 404… Any idea why that may be?

    Thanks a lot!

  4. anon no dia 18 de Nov de 2009 às 20:54

    Hi, thanks for the plugin. I’m wondering, what’s the easiest way to get the custom author base value from somewhere within one of my templates? I see your plugin only adds a rewrite rule and doesn’t alter the DB like your previous plugin, so I’m curious how you suggest this should be done. Thanks.

  5. Milan no dia 14 de Fev de 2010 às 13:42

    Will you provide option to add any .htaccess rule, not just one for rewriting?

  6. Aleksey no dia 12 de Abr de 2010 às 12:58

    I already have custom rules in .htaccess, when install plugin. And after installation, i didn’t see my already exist .htaccess, it’s ok?

  7. Aleksey no dia 12 de Abr de 2010 às 13:08

    Also, it’s breaks quotes in custom rules, adds backward slash (“\”).

  8. christopher gaston no dia 23 de Abr de 2010 às 22:26

    Is it possible to have the base name removed altogether? I can place a single period in the field and the link points to http://www.root.com/admin which is what I desire.
    But I get 404 not found when I click on the link.

  9. JAB_au no dia 2 de Mai de 2010 às 2:58

    When I installed 1.5.1 it removed the WordPress entries from the .htaccess file when I made a change using the plugin. All my permalinks failed.

    Had to re-insert the following lines that had been removed:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

  10. Arjen no dia 23 de Jun de 2010 às 18:59

    I have installed the plugin succesfully and selected the advised settings. Now I can’t use my site anymore. Both the admin and all other pages are not accessible anymore.

    Anybody a solution for this problem I encounter?

    • Arjen no dia 23 de Jun de 2010 às 19:01

      This is the message the browsers shows:
      Internal Server Error
      The server encountered an internal error or misconfiguration and was unable to complete your request.

      Please contact the server administrator, support@mijndomein.nl and inform them of the time the error occurred, and anything you might have done that may have caused the error.

      More information about this error may be available in the server error log.

      Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    • dardna no dia 23 de Jun de 2010 às 19:07

      For the moment try deleting the .htaccess file on the root of your wp installation.
      If not enough also delete this plugin files (this shouldn’t be needed).
      Afterwards try each “suggested rule” with care, one at a time.
      Hope this helps, get in touch if still in trouble.

    • dardna no dia 23 de Jun de 2010 às 19:20

      Don’t use the canonical setting. I’ll be removing/explaining it in the future.

  11. Morgan no dia 25 de Jul de 2010 às 7:30

    Hi,

    I installed this, changed a couple parameters, saved it, and now I can’t change any of those parameters, even when I deactivate and reactivate.

    Maybe it’s because I disabled access to .htaccess in the settings? I don’t know. I did download the htaccess via ftp to see if those changes were there and they didn’t seem to be.

    I am running multisite so maybe this changes something. please let me know if i’m doing something wrong. Thanks.

  12. Agnes no dia 17 de Ago de 2010 às 11:19

    Hi
    This sounds like a great polugin, unfrotunately does not seem to work with me…
    I am with WP 2.9.1
    I have a current .htaccess file at the root of WP site, with custom 301 redirections. I was homing I cold use the plugin to edit it and add some things on the go.
    WHat happens is: whatever I specify in the plugin settings, I say “save all changes”, and nothing happens:
    - nothing shows in the “current htaccess file as is generated by WP”
    - my htaccess file is not updated.
    Do I do shg wrong?
    Thanks
    Agnes

  13. Agnes no dia 17 de Ago de 2010 às 13:46

    Hi and thanks for the prompt answer.
    I had a permalink in place online but not on my test local site… Now, I’ve put it on (a personalized one with /%postname%/), but still does not work. Is annoying…
    What I do:
    - I have my local website .htaccess at root, it is declared under apache module. It is customized with a number of instructions.
    D:/Documents/Websites/www.wordpress.net/.htaccess
    - I have one group under that module, called “muy htaccess”
    - I have added one new redirect there
    - my htaccess file is open in DW but does not prompt to reload…
    Am I doing sthg wrong?

    • dardna no dia 17 de Ago de 2010 às 16:18

      Agnes, it’s hard to diagnose from your description…

      Is “Current htaccess file as it is generated by WordPress” still empty? It should be filled from the moment you “Save all changes”, even if you haven’t filled any option…

      Are you 100% sure you’re looking at the right file? I believe Dreamweaver doesn’t block files but have you tried without having the file open?

      Are you using any other plugin that could be causing conflict? Does the plugin work on a vanilla (clean, new) installation of WordPress, on the same server/environment? Have you tried upgrading WordPress?

      Again, it’s hard to spot the error this way, maybe you care to give me access to a test environment…

  14. Agnes no dia 17 de Ago de 2010 às 16:38

    Yes I am working on the right file
    I dont think another plugin causes conflict…
    I rather think I have trouble to understand how to setup this plugin…
    In fact, I can’t find more
    “Current htaccess file as it is generated by WordPress”
    although I remember I saw it!
    I also tried entering sthg in Apache .htacess brut: field, but it does not do anything.

    OK, rather than debugging me, may be you could tell me what would be the simple and good manner to set up the plugin to do what I want? ie:
    edit an existing complex htaccess file
    (or import it and add things to it from the plugin admin page)

    Then I can try from a clean version… and then on my remote server

    Thanks!
    Agnes

    • dardna no dia 17 de Ago de 2010 às 16:50

      Ok,

      “Current htaccess file as it is generated by WordPress” is at the bottom of the plugin page.

      This plugin won’t edit your already existing htaccess (it doesn’t read the existing file, it always generates a new one).

      You should pick your complex rules and paste them on “Custom htaccess” (maybe rename your old htaccess) and then “Save all changes”. WordPress will then generate a new htaccess file, including those custom rules before its own.

      Hope this helps.

  15. Agnes no dia 31 de Ago de 2010 às 8:05

    Hi Antonio
    I have to apologize, I realize I was communicating here and trying use another plugin, redirection from urbangirafe. Thus the problems with finding the right approach and menus!
    Now I ve used just yours, and it works fine as you say.
    However, I have one suggestion.
    My purpose again is to use your plugin to easily edit and add rules to a complex htaccss file, where I have my own redirections rules, as well as some customized WP rules (not those of JPMorgan you included, but specific ones he helped me to build through another forum – for some reason the included rules do not work well in this configuration)
    So, Thanks the plugin I can put all this customized stuff before WP block, but the problem is, if I save through the plugin, it will still always add the normal WP blocka fterwards, which is wrong.
    Would it be possible to add an option to omit it?
    Thanks for tyour great work
    Agnes

  16. Agnes no dia 1 de Set de 2010 às 8:08

    Great, wonderful, I’ll fetch it, thanks!

  17. Agnes no dia 2 de Set de 2010 às 9:37

    Hello Antonio

    I am playing with the new plugin v1.7, and it does work great! I am now able to easily edit and modify my htaccess rules, that is a great new thing which was not available anywhere before (I searched hard!)

    Little more suggestions re this new feature:
    - When I use this new “WP htaccess” block, on the side you give the “original rules”.
    It is little confusing because these “original rules” seem to keep some customized things from other parts of the plugins admin, though the generated htaccess does not.
    Example: I reset all. Then I copy the normal WP rules in this field, and then I add one pair. The pair does not appear in the “current htaccess as generated by WP” (and it does not show up in the .htaccess file indeed), but it appears in the “original rules” side aid of the “WP htaccess” section. Which is wrong?
    - May be you should specify in the grey comments, that using this field will replace / override any other setting placed here (author base, pairs, etc)
    - in terms of wording, I would thus call this new “wordpress htaccess” field something else, as opposed to “custom htaccess” above. May be “custom htaccess initial rules” (for the ones that appear before WP rules) and “custom htaccess set of rules” (for the one that replaces WP ones)?
    And then place that new block last, as it does not combine with other customization options.

    Other difficulties and suggestions not related with this new feature but rather with rewritebase & pairs:
    - as you give many options, why not get customized the rewritebase? It would make it easier when working on localhost version.
    - In fact, I am not sure if I am doing sothg wrong, but I can’t get the pairs work because of the rewritebase I think…
    For some reason (when I reset all) WP has defined my rewritebase as
    RewriteBase /www.mysite.com/
    Although I am on http://localhost/www.mysite.com
    So the pairs I request get written byt he plugin for example to:
    RewriteRule ^specialites-italiennes /www.mysite.com/buffet-italien [QSA,L]
    Which won’t work.
    It works though if I put the following rule using the custom htaccess field that inserts this instruction above the WP block:
    RewriteRule ^specialites-italiennes http://localhost/www.mysite.com/buffet-italien [QSA,L]
    - Another difficulty with the rewrite base and pairs is: when I want to redirect to the HP, either I put nothing in the target URL field (and the pair is not accepted) or I write again the full path, but it gets concatenated with the base and goes wrong…! I’ve tried index.php as well, but since my base is wrong I am not sure if it works…
    - To make it easier for user to figure out how to write the destination URL, I would put an example below the “rewrite pairs”, or even better, sthg that immediately shows the output that will be generated. One gets it on bottom with “saving changes” for sure, but one does not like to save wrong changes blind!
    And if I use the custom field above to edit all my rules, I still could use the “pair” feature to help write and copy/paste them.
    But this i really finetuning.
    - Also, It would be better to keep “Reset all rules / save changes” buttons visible even when one collapses the rewrite pair.

    Thanks a lot!
    Agnes

Deixar uma resposta

8 trackbacks

  1. dump » WP htaccess Control no dia 8 de Abr de 2009 às 2:52
  2. Editar el htaccess desde el panel de administración de Wordpress | Punto Geek no dia 13 de Abr de 2009 às 19:04
  3. WP .htaccess Control, edita el .htaccess sin FTP « [Ray] Page no dia 14 de Abr de 2009 às 16:26
  4. Modifica htaccess desde Wordpress - URIELMANIA no dia 14 de Abr de 2009 às 19:23
  5. WordPress Plugin Releases for 04/02 « Weblog Tools Collection no dia 5 de Fev de 2010 às 20:32
  6. WordPress Plugin Releases for 04/02 no dia 17 de Mar de 2010 às 10:36
  7. Top Wordpress Plugins July 2010 - Allora Visuals | Allora Visuals Blog no dia 14 de Jul de 2010 às 22:05
  8. How to Make WordPress Ignore the Subdomain | The Helpful Coder no dia 23 de Ago de 2010 às 21:03