Adding .html to pages created by plugin with new base name like /portal

Home Forums BulletProof Security Pro Adding .html to pages created by plugin with new base name like /portal

Viewing 15 posts - 1 through 15 (of 43 total)
  • Author
    Posts
  • #4936
    Andre
    Participant

    Hi,

    I am using wpclient and it adds pages to the site, that follow this url structure: /portal/hub-page/ the thing is … I am using a plugin thats adding .html to all pages. so, the site created by wp-client is called /portal.html and when visited ends in /portal/hub-page/ with a 404…

    I woul dlike to call the pages differently (because of my german site) then update them as the portal pages used by wp-client and then correct the addition of the .html to those pages over an htaccess rule.

    As I want a natural link structure (static look) and I already made a lot of redirects to all the pages, I thought of an htaccess rule similar to what is explained http://stackoverflow.com/questions/5745490/rewrite-rule-to-add-html-extension

    I would try it like this

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/portal/
    RewriteRule ^(.*)$ $1.html

    The plugin that add .html to pages is not very big, maybe the community also has an idea to add anything here:

    <!--?php /*
    Plugin Name: .html on PAGES
    Plugin URI: http: //www.introsites.co.uk/33~html-wordpress-permalink-on-pages-plugin.html
    Description: Adds .html to pages.
    Author: IntroSites
    Version: 1.1
    Author URI: http: //www.introsites.co.uk/
    */
    
    add_action('init', 'html_page_permalink', -1);
    register_activation_hook(__FILE__, 'active');
    register_deactivation_hook(__FILE__, 'deactive');
    function html_page_permalink() {
    global $wp_rewrite;
    if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
    $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
    }
    }
    add_filter('user_trailingslashit', 'no_page_slash',66,2);
    function no_page_slash($string, $type){
    global $wp_rewrite;
    if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
    return untrailingslashit($string);
    }else{
    return $string;
    }
    }
    
    function active() {
    global $wp_rewrite;
    if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
    $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
    }
    $wp_rewrite->flush_rules();
    }
    function deactive() {
    global $wp_rewrite;
    $wp_rewrite->page_structure = str_replace(".html","",$wp_rewrite->page_structure);
    $wp_rewrite->flush_rules();
    }
    ?>
    #4938
    Andre
    Participant

    I think also the trailing slash should be taken away in the rule, so that the link ends in : /portal/hub-page.html

    The internal redirect by the plugin wp-client to /hub-page could also be a problem, cause the site itself still is called /portal.html (because the plugin adding .html to all pages) and the /hub-page is added by wp-client obvisously.

    Other sites created are like:

    /portal/add-staff.html which sorks cause nothing like /hub-page is added by wp-client.

    Hubpages that are created for or by a client seems to also work correctly, like /?hubpage=test212 seem to work.

    So probably only /portal/hub-page/ and /portal/login-page/ (which wants to show up after logout of wordpress seem to be due for rewrite condition….

     

    The other possibility would be to roll back completely the site from .html endings, which I see aas a whole lot more work, or could this be achieved easier also with a rewrite rule? (to avoid 404 errors in webmaster central, cause by going back to no file ending)

    #4949
    AITpro Admin
    Keymaster

    Can you summarize exactly what you want?  I am confused by what you are asking.

    #4954
    Andre
    Participant

    🙂

    I am confused myself, thats why.

    The first problem: On installation the plugin wp-client created pages for working. For example a client account, overview page, invoicing, blabla. In this wp-client plugin the hub is a thing where anything related to a client will be gathered, documents, files, etc. Like a dashboard page, showing in frontsite. Clients never get to backend. This hub page is one of the two pages not redirecting correctly.

    This one “virtual page” it created is /portal/hub-page/. When I would not use a plugin called .html for pages, which adds .html also to pages (additionally to the permalink structure which only covers posts, etc), then the /portal/hub-page/ would simply be working when visited, I mean, wouldnt give a 404. Because /hub-page/ probably is virtual somehow, comeing from wp-client it has this URL ending issue. See it this way: There is a parent page that is created, it is called /portal.html (the .html comes from the small plugin) and when visited it ends in /portal/hub-page/ with a 404 error. Get me? /portal.html would probably normally be just /portal because of the slug, but the html plugin adds .html. The hub-page comes from the plugin settings of wp-client and, I dont know why exactly, but it is added to the /portal , when visiting the link, respectively it is added to the portal.html… that causes the 404 error.

    This is the problem, all the opther pages created are like /portal/add-staff.html and can be visited just fine (probably because /hub-pages/ isnt added “virtually”)

    I would say, that hub-pages comes from calling a refernce anywhere in the php code of wp-client, because when a client hub page is created (comes through adding a client portal) then it ends in anythign dynamic like: /?hubpage=test212 which again seems to be working or, at least, can be visited.

    The second problem is, when logging out the standard /wp-login.php?loggedout=true is somehow “virtually” redirected to /portal/login-page/ which also gives a 404.

    Then I thought about options. The first is maybe an htaccess rule like:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/portal/
    RewriteRule ^(.*)$ $1.html

    The second could be making changes to the plugin .html for pages.

    The third and probably worst and most exhausting would be to roll back to permalink structure without .html. Maybe this could be easyly done with redirecting code to avoid problems with 404 and 500 errors popping up in webmaster central… donno.

    Get me better now?
    Andre

    #4971
    AITpro Admin
    Keymaster

    Ah the dreaded .html permalink hack.  It was a bad idea years ago and it is still a bad idea today.  With that said you can continue to use it, but expect problems such as the ones you are experiencing.  That is just what happens when you hack the standard WordPress custom permalink structure.  😉

    Personally I would get rid of the html hack, but that is just me.

    RedirectMatch 301 ^/(.*).html$ http://www.ait-pro.com/$1

    Or do something like this if required/necessary to take care of the 404 errors.

    http://stackoverflow.com/questions/11926237/redirecting-old-html-page-to-new-without-html-extension-page

    I cannot really advise you any further on what to do.  This is a personal choice that you will need to make for yourself.  You can either keep your .html hack and rewrite per page or overall, but I do not want to get into figuring out everything you will need for this site.  You may need to create some individual rules for specific pages and then also use an overall rule to handle things generally.

    #4975
    Andre
    Participant

    Hi,

    so  option 3 also with having in mind, that I need to start to set up the wp-client cleanly, by now, and get finished with hacking around and trrying this and that, but be productive… 🙂

    This would mean, I have the redirections in the htaccesss from my old urls (after the site re-launch to wordpress), have the older 404 and 500 error corrections still inside the custom code (that I just corrected yesterday (probably caused by the .html structure too) ) and then additionally

    RedirectMatch 301 ^/(.*).html$ http://www.my-site.com/$1

    to be added after I have rolled back the permalink structure?
    Can You confirm?
    This is a current redirect I had to make because google moaned about it:

    Redirect 301 /php-javascript-ajax-html5-xhtml-css-web-technologien.html/wine http://www.web-assembler.com/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien.html

    It does well look to me, that the image links (wine is an image) are also handled incorrect because of the lame .html hack and the hack would probably constantly cause problems right?

    Thanks for Your consultation on this problem, too again.

    I love Your support.
    Andre

    #4981
    AITpro Admin
    Keymaster

    What you need to do is isolated testing before you do a sitewide change/rewriting.

    Use ONLY 1 .html URL that you can test with and create a specific redirect for that URL.  Then doing a wider test.

    What are you trying to do here?  It does not make sense to me and I do not understand it and it is definitely not valid.  Please explain what you are trying to do.

    Redirect 301 ^/php-javascript-ajax-html5-xhtml-css-web-technologien.html/wine http://www.web-assembler.com/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien.html

    If wine is an image file then what is the full name of that image file?  Also why would you be trying to redirect an image to another page?

    #4982
    AITpro Admin
    Keymaster

    Also try to keep your explanations short and simple and not write a book.  😉

    Examples:
    I have this file X that I want to redirect to this Page X.
    I have this Post X that I want to redirect to this Page X.
    I have this Category X and Post X that I want to redirect to this Category X and this Post X or Page X.

    #4995
    Andre
    Participant

    Hi, I already try to keep it short and simple, but this comes a bit from my german origin, cause sentences in german are quite long in relation to english.

    with:

    Redirect 301 /php-javascript-ajax-html5-xhtml-css-web-technologien.html/wine http://www.web-assembler.com/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien.html

    I was avoiding a 404 that was found by webmaster central, thats all. As long as it is not leading nowhere… better it is. Got several of this kind. And yes, I will test before I completley change URL structure.

    Cheers.

    #4996
    AITpro Admin
    Keymaster

    I naturally tend to say too much so I have to force myself to keep it short.  What happens when you say too much is people start getting confused – too much information.  So you have to say as much as possible to get everything important out and try and keep the details concise and focused, which is very challenging for me to do.

    I still do not understand what you are trying to do.
    please state exactly what “wine” is and if it is an image file then state wind.jpg, etc.
    Use this format to describe what you are trying to do.
    I have this file X that I want to redirect to this Page X.
    I have this Post X that I want to redirect to this Page X.
    I have this Category X and Post X that I want to redirect to this Category X and this Post X or Page X.

    #4998
    Andre
    Participant

    Okay. I have this link: http://web-assembler.com/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien.html

    in this page are images, one of them is http://web-assembler.com/wp-content/uploads/2013/03/wine.png

    I dont want to necessarily redirect, I just wanted to correct the 404 error Google webmaster central noted to me which was /php-javascript-ajax-html5-xhtml-css-web-technologien.html/wine

    Only way I know is a redirect from dea link /php-javascript-ajax-html5-xhtml-css-web-technologien.html/wine to any working page, like web-assembler.com/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien.html ONLY to avoid the 404 error, and therefore I took the page I know the image is published on.

    Short enough?

    Sometimes short is not possible. Or I make bulletpoints, very unpersonal. 🙂 Dude

    #5000
    AITpro Admin
    Keymaster

    Oh ok I understand now.  This is what you need.  Important Notes:  Use RedirecMatch NOT Redirect, use the caret for the start of URL, use the $ sign for the end of the URL and DO NOT use a back reference $1.  You cannot use the first part of the URL or else you will end up with an infinite redirect loop.  If you have any other posts or pages with “wine” in the URL then they will also be redirected.  If you do have other posts or pages with “wine” in the name/URL then you will have to add additional specific identifiers in your redirect code that will only match this and not match anything else.

    RedirectMatch 301 ^/wine$ http://www.web-assembler.com/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien.html

    Or probably a better approach is to not try and redirect back to the same page and instead redirect to any other page just to get rid of the 404 error.

    RedirectMatch 301 ^/php-javascript-ajax-html5-xhtml-css-web-open-source-technologien(.*)/wine$ http://www.web-assembler.com/choose-another-page-to-avoid-a-redirect-loop.html
    #5003
    Andre
    Participant

    Great, understand the syntax and will do… Cause avoiding 404 is far more important than having a .html -structure. That was mostly to try to make as much use of seo, as possible.

    #5004
    AITpro Admin
    Keymaster

    On a regular basis I have to create all sorts of RedirectMatch rules because 404 errors build up constantly.  These 404 errors are coming from a Stats website that is grabbing my URL’s and is mixing them up with other website’s URL’s.  I basically just send all of them to my home page.  This means that I can handle 100’s of bad URL’s from this Stats website in under 10 minutes of my time per month.

    #5006
    Andre
    Participant

    Nice, to know more of it, where do I learn all those regex from, BTW???

    Yes, definetely is working batches a nice thing!!!
    Is the coding in htaccess coming from C programming language, yes?

    RedirectMatch 301 ^/php-javascript-ajax-html5-xhtml-css-web-technologien.html$ http://www.web-assembler.com/

    Is this correct syntax? the dollar stops apache from looking further, correct? and the $1 would make the apache point anything to the expression that was described…

Viewing 15 posts - 1 through 15 (of 43 total)
  • You must be logged in to reply to this topic.