Using WordPress Permalinks

Discussion in 'Third-party applications' started by frekster, Mar 15, 2011.

  1. Hi,

    I cannot get WordPress Permalinks to work. Looking at this documentation:

    http://codex.wordpress.org/Using_Permalinks

    is it possible to use the permalinq feature on the Winhost server? I've set permalink up in my WordPress control panel, all looks fine, but when I navigate to a URL using a permalink it will not load the blog post so something is just not write on the server. How can I get it to work? Can someone please post me instructions? What must I adjust on the server to get a permalink to resolve properly?

    thanks!

    Justin
     
    Last edited by a moderator: Oct 14, 2015
  2. Hi,

    thanks for the quick response!

    Yes, I came across that and tried it but am not having much luck. In the root of my web application folder I have a rewrite rule in place to rewrite request to my blog as blog.mycompany.com.

    The article states to have the web.config file in the same folder as the php WordPress files. My WordPress is installed into a /blog sub folder within my root. I put a web.config file in /blog sub folder with his rule but it generates a 404 error.

    So my parent folder has a rewrite rule in web.config to rewrite to blog.mycompany.com, and now this child web.config has a rewrite rule.

    Question... should I put both rewrite rules in the root site web.config file and delete the web.config file in the /blog sub folder?

    thanks for any help or ideas!

    /Justin
     
  3. Ray

    Ray

    The redirect script should not go in the subfolder where your blog application resides but on the root. 404 is fairly a straight forward error meaning it cannot find something. Do you have a URL we can look at to see the error?
     
  4. Hi Ray,

    Hey man you are famous around here! :)

    thanks for the response.

    my blog is at http://blog.blindsoftware.com

    if you click on the only post there "the top three screen readers..." the next page gives the 404.

    I've deleted the web.config file in my /blog sub folder. I've placed two rewrite rules in my web.config in my root. Here is what I have:

    <rewrite>
    <rules>
    <rule name="blog.blindsoftware.com" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny">
    <add input="{HTTP_HOST}" pattern="^blog.blindsoftware\.com$" />
    </conditions>
    <action type="Rewrite" url="\blog\{R:0}" />
    </rule>
    <rule name="PermalinkRule" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" />
    </rule>
    </rules>
    </rewrite>

    thanks man if you can help me!

    /Justin
     
  5. He's famous everywhere he goes. You should see the guy.
     
  6. He's world famous, I can tell! :)

    I am hoping you guys can help me figure out this situation I am having with the url rewrite... I am so close to figuring it out I can taste it but cannot crack the code!

    help!

    /Justin
     
  7. Ray

    Ray

    Let me get this straight and do a quick recap to make sure I understand what you are trying to accomplish.

    If you have WordPress uploaded to a subfolder called "Blog".

    When someone types http://blog.blindsoftware.com you want it to get redirected to the subfolder "Blog" and pull up the file "index.php".

    You want to clean the URL so that it does not display blog.blindsoftware.com/blog/index.php but merely display in the browsers address bar blog.blindsoftware.com.

    I think I understood it right?
     
  8. Sorry man that is not correct.

    I have the http://blog.blindsoftware.com working fine pointing at the /blog folder. That is not a problem at all. The problem is using pretty permalinks in WordPress.

    By default, WordPress shows urls like this:

    http://blog.blindsoftware.com/?p=33

    which is not seo friendly at all using that id stuff.

    So the WordPress documentation suggests to use permalinks - a way to rewrite the URL to be seo friendly. So instead of using the ?p=33 it is rewritten to be:

    http://blog.blindsoftware.com/2011/...reen-readers-for-the-blind-which-is-the-best/

    Really, that url points to http://blog.blindsoftware.com/?p=33 but is displayed in the address like what I am showing you there.

    If you look at hank's comment a bit earlier, he posted a link to an article that showed how to get permalinks to rewrite properly using the URL rewrite module in iis 7 manager.

    The first rewrite rule I posted is the one that works fine... blog.blindsoftware.com. That is not an issue. The problem is getting the new PermaLinkRule to work. It is not configured properly and is giving a 404 error - page not found.

    So when a person pastes this into their address:

    http://blog.blindsoftware.com/2011/...reen-readers-for-the-blind-which-is-the-best/


    it should pull up the blog post and show it. Right now it is giving a 404 because something is not being constructed properly in the rewrite rule for the PermaLinkRule I pasted in a prior post (a few lines up here).

    If you read over that link Hank pasted in a few lines up, it will show you exactly what I am trying to accomplish.

    Hope this is making sense.

    Hoping you can help me crack this one.

    Thanks Ray for the help!

    /Justin
     
  9. Ray

    Ray

    I believe the permalink settings are inside the WordPress admin sections. I don't think you actually need to setup the rules for it. What you need is to setup the rule for the subdomain name blog.blindsoftware.com so that it points to your WordPress app. The rest of the rule I believe WordPress will handle.
     
  10. Hey Ray,

    Yup, you would think that it would work that way but it is not, unfortunately. This was why I was investigating a URL rewrite rule. I now have reverted back to only having the blog.blindsoftware.com rewrite rule and I have removed the PermaLinkRule from my web.config. I went back to my admin area, permalinks, and set it to use this format:

    http://blog.blindsoftware.com/index...en-readers-for-the-blind-–-which-is-the-best/

    however, I am getting a 404 error still. So this default setup is not working and I am not certain why.

    If I use this URL it works fine:

    http://blog.blindsoftware.com/?p=20

    According to the above link that Hank pasted in, the guy in that post was having the same problem as I am having. He had the admin permalink chose but kept getting a 404.

    For some reason under iis, there is some sort of quark with using the permalinks with WordPress.

    If you have access to my website folder and web.config, please feel free to tinker with it some. I flat out cannot get the blasted thing to work.

    Help!

    /Justin
     
  11. Ray

    Ray

    The...

    HTTP Error 404.0 - Not Found
    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

    Physical Path E:\web\blindsof\blog\2011\03\15\the-top-three-screen-readers-for-the-blind-which-is-the-best\

    ...error is showing this physical path. Obviously this does not work because there is no physical path within the folder blog to 2011. The folder 2011 exist within another subfolder.

    Try this for now. Try bypassing the rule and simply pull up your WordPress...
    http://www.blindsoftware.com/blog/index.php

    Lets work on that first and get the pretty permalink working first. Then starting dealing with redirect subdomain names.
     
  12. Ray,

    I have commented out the blog.blindsoftware.com rule in web.config.

    If I go to www.blindsoftware.com/blog/ it comes up fine. I have permalinks turned on but I am still getting a 404 using the permalink of:

    http://blog.blindsoftware.com/index...en-readers-for-the-blind-–-which-is-the-best/

    Are you able to get permalinks working on your install of WordPress?

    I followed your guide so I am assuming you have WP installed there somewhere :)

    Have you been able to get permalinks working?

    If I use the default permalink format of:

    www.blindsoftware.com/blog/?p=20 it works fine.

    It's only when I try to adjust that format to use a seo friendly URL and choose a different permalink format.

    Any ideas?

    thanks!

    /Justin
     
  13. Ray

    Ray

    I think the pattern you are using maybe holding up Wordpress...

    /the-top-three-screen-readers-for-the-blind-–-which-is-the-best

    Try using a more simple pattern for now. In the settings for the Permalink try the default settings first before you start using the Custom Structure.

    Also, if possible send us a screenshot of your Permalink Settings in WordPress.
     
  14. OMG! I am going to smack myself!

    I installed WordPress into a /blog subfolder and not in the root of my website. I.E

    www.blindsoftware.com/blog/

    The original URL rewrite rule assumed you were in the root and not a subfolder so it was not working. Notice the index.php URL below:

    <rewrite>
    <rules>
    <rule name="WordPressRewriteRule" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" />
    </rule>
    </rules>
    </rewrite>

    Notice it is just index.php in the rewrite section of the URL - assuming you are installed to the root of your website.

    Since I have WordPress in a /blog sub folder, it needed to be this:

    <rewrite>
    <rules>
    <rule name="WordPressRewriteRule" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="blog/index.php" />
    </rule>
    </rules>
    </rewrite>


    and then in WordPress, in the permalink settings, I chose custom format and used this format:

    /%year%/%monthnum%/%day%/%postname%/

    So now this URL is working:


    http://www.blindsoftware.com/blog/2...en-readers-for-the-blind-–-which-is-the-best/

    However, I do not want the URL to be this I want it to be the following:

    http://blog.blindsoftware.com/2011/...en-readers-for-the-blind-–-which-is-the-best/


    So this means I need to use another rewrite rule. This is probably going to take me a while to figure out but at least this part is working and posted for someone else to use. If I get blog.blindsoftware.com working I'll post the solution.

    stay tuned!

    coffee... coffee... more coffee...

    /Justin
     
  15. ok, that was a bit easier than I had expected. After following the steps in post #15, here is the complete url rewrite syntax to use pretty permalinks with http://blog.mycompany.com
    Note: replace blog.mycompany.com with the real name of your website.

    <rewrite>
    <rules>
    <rule name="WordPressRewriteRule" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="blog/index.php" />
    </rule>
    <rule name="blog.mycompany.com" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny">
    <add input="{HTTP_HOST}" pattern="^blog.mycompany\.com$" />
    </conditions>
    <action type="Rewrite" url="\blog\{R:0}" />
    </rule>
    </rules>
    </rewrite>


    After you put that in web.config, go to the WordPress admin, settings, general and set the site URL to be http://blog.mycompany.com and click save.

    that's it. Now pretty permalinks will work such as:

    http://blog.mycompany.com/2011/03/23/finally-permalinks-work/

    hope this helps someone out there... main thing to remember is that all of this information assumes you have installed WordPress into a /blog sub folder and *not* into the root of your website.

    oh the pain...

    /Justin
     
  16. Ray

    Ray

    Glad to hear you got it working and thanks for the follow up.
     
  17. Justin,

    Thanks for posting the rewrite rules, I almost have my installation working now. When I go to blog.mydomain.com, the wordpress install is showing up, but without formatting. Firebug and JSView tell me that the css files is being called appropriately, referencing blog.mydomain.com/wp-content/themes/twentyten/style.css, but it cannot be found.

    So this means that while the subdomain is pointing at the /blog directory for the index.php file, apparently it does not recognize that the "blog." subdomain should ALWAYS reference the /blog directory.

    I already set the /blog folder up as an application starting point, as I read here on the forums that you have to do so.

    Does anyone have any input on what I'm missing here?

    Thanks,

    Warren
     
  18. Ray

    Ray

    Have you tried updating wordpress to look for the css files using an absolute path rather then the relative path. You may need to go through it and have the path set and look something like this...

    /wp-content/themes/twentyten/style.css

    ...instead of

    blog.mydomain.com/wp-content/themes/twentyten/style.css
     
  19. Other way around. /wp-content/ is relative. http://blog.mydomain.com/... is absolute.

    Any way, I am already utilizing relative references to call these files. The problem is, the rewrite rules are pointing to the blog/index.php file for URLs containing the "blog." subdomain so the permalinks work, but the template calls do not.

    I'm a linux guy, so the windows web.config XML-based syntax is a little alien to me, but since my company uses ASP and Access DBs I'm kind of stuck with it. I just need to figure out what I'm missing.

    I'm one of the countless customers who find it odd that pointing a subdomain at a subfolder isn't an automated process here. Even GoDaddy had that, and the windows server they had us on timed out constantly so we are seeking alternatives. If we can't get this fixed up, we'll have to keep looking. Hate to do that, since the price is a lot better here than elsewhere.
     
  20. Not to put too fine a point on it, but maybe GoDaddy's service is inferior to ours because they do some things that we don't do. Just saying. ;)

    That automation is something we talk about, but the implementation is complicated by they way a Winhost account/site is configured and the way a Windows server works. If it were simple and easy we would have done it already.

    It's not off the table though, it is still up for consideration.
     
    Last edited: Oct 14, 2015
  21. Well, I have the subdomain working now, the permalinks work, so all of the text is there and such. The only problem is, the CSS still isn't showing up. It's being called properly, at /wp-content/themes/mytheme/style.css, but it 404s out. There must be something I'm missing here. The URL rewriting is happening, and the content is there, just not called files.

    Anyone have any ideas? We're going to have to move on to a different host soon. Management is getting impatient.
     
  22. All I need is someone who is using Wordpress in a subdomain with "pretty permalinks" to send me their web.config file so I can modify it for our use.

    Someone out there HAS to be doing this, right?

    If this happens, for the love of all that is holy, make the post a sticky or something so no one else has to spend two weeks on this. I guarantee this will save you countless customers, Winhost.
     
  23. Ray

    Ray

    I don't think anyone will do that since the web.config file can have some sensitive information in it. Rather look in this thread and "frekster" has a posting that gives an example on how to fix what you are trying to accomplish.
     
  24. Ugh. I of course read the entire post, as well as EVERY OTHER post on the topic in the forums, obviously to no avail.

    I have followed frekster's directions to the letter. That's what has brought me to this point. The permalinks work, but the references to the css, though well-formed, 404 out.

    As for sensitive information, I'm sure anyone who knows enough to complete this task would know enough to remove anything sensitive before sharing first.

    I guess the search for a new host continues. This is obviously going nowhere and we're just not seeing enough dedication to customer support for something that should be the least of our worries in the moving process. This is the ONLY thing holding us back from switching DNS at this point.
     
  25. Ray

    Ray

    Do you have a URL or link we can look at and test so we can see the problem ourselves?
     
  26. URL sent through PM. Also just noticed, I cannot access wp-admin using frekster's instructions either.
     

Share This Page