Check out some of the wordpress tutorials on building your own theme. Some of them have all sorts of slick code in the head section and on the body to generate code.

Have to say though, if I was doing anything like a blog, I would definitely just use wordpress and do my own theme. A normal work year for one person is 2000 hours. I'll bet they have at least 30,000 hours into that development, minimum. Why reinvent the wheel?

    Hi Brad,

    Seems there is a learning moment for me here.

    How does the index have access to the orginal URL? I was indeed wondering where wordpress got the info from, and did not feel like speculating 😃

      edziffel;10985048 wrote:

      Check out some of the wordpress tutorials on building your own theme. Some of them have all sorts of slick code in the head section and on the body to generate code.

      Have to say though, if I was doing anything like a blog, I would definitely just use wordpress and do my own theme. A normal work year for one person is 2000 hours. I'll bet they have at least 30,000 hours into that development, minimum. Why reinvent the wheel?

      hm.. And what if you have a website with all sorts of user-modules already and you just want to add a blog? Would that still be the case? Is there an easy way to link your own user management and tell wordpress a certain person is logged in & a registered user? I a in a situation that I have a website, but would like to add blogging functionality. I indeed wanted to link to wordpress, but could not find an easy way (I do not of course want my user to create 2 accounts and have to log in twice for my site).

        edziffel;10985048 wrote:

        Check out some of the wordpress tutorials on building your own theme. Some of them have all sorts of slick code in the head section and on the body to generate code.

        Thanks very much for this. I'll check one of the themes.

        edziffel;10985048 wrote:

        Have to say though, if I was doing anything like a blog, I would definitely just use wordpress and do my own theme. A normal work year for one person is 2000 hours. I'll bet they have at least 30,000 hours into that development, minimum. Why reinvent the wheel?

        Only because I'm not building a blog.

        leatherback;10985049 wrote:

        Hi Brad,

        Seems there is a learning moment for me here.

        How does the index have access to the orginal URL? I was indeed wondering where wordpress got the info from, and did not feel like speculating 😃

        I would also be very interested in learning how the line you posted retrieves the pertinent info.

        Thanks to everyone for your time!

          Try using the same .htaccess as above and redirect to your own PHP script. Then do a [man]print_r/man on the $_SERVER array - you should find the URL you typed in that was redirected to the PHP script.

            Well, I don't quite understand what transpired:

            Array
            (
            [DOCUMENT_ROOT] => /home/account/public_html
            [GATEWAY_INTERFACE] => CGI/1.1
            [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
            [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
            [HTTP_ACCEPT_ENCODING] => gzip, deflate
            [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
            [HTTP_CACHE_CONTROL] => max-age=0
            [HTTP_CONNECTION] => keep-alive
            [HTTP_COOKIE] => fc=fcVal=2348379668274393764; PHPSESSID=7f142429fbd8be97dbc69b0b3d96d000
            [HTTP_DNT] => 1
            [HTTP_HOST] => www.account.com
            [HTTP_USER_AGENT] => Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0
            [PATH] => /bin:/usr/bin
            [QUERY_STRING] =>
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => TjAqm63NfbcAANQJDnoAAAAK
            [REDIRECT_URL] => /dearly_beloved
            [REMOTE_ADDR] => 67.216.147.129
            [REMOTE_PORT] => 46389
            [REQUEST_METHOD] => GET
            [REQUEST_URI] => /dearly_beloved
            [SCRIPT_FILENAME] => /home/account/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SERVER_ADDR] => 173.205.125.183
            [SERVER_ADMIN] => webmaster@account.com
            [SERVER_NAME] => www.account.com
            [SERVER_PORT] => 80
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SIGNATURE] =>
            [SERVER_SOFTWARE] => Apache
            [UNIQUE_ID] => TjAqm63NfbcAANQJDnoAAAAK
            [PHP_SELF] => /index.php
            [REQUEST_TIME] => 1311779483
            [argv] => Array
            (
            )

            [argc] => 0

            )

            I see the request and redirected URL are the same. Shouldn't it be different? Maybe I was supposed to do the print_r on a wordpress install?

              schwim wrote:

              Shouldn't it be different?

              Nope. Since you're rewriting the URL internally (e.g. you didn't have a full URI that begins with 'http://'), Apache knows that there's no sense in actually redirecting the user to the new URL (unless, of course, you use the [R] flag on the RewriteRule), thus the URL rewriting is done transparently by the inner workings of Apache. Thus when PHP gets the request, '/dearly_beloved' really is the 'request URL' since that is the most recent request the client has made.

                I did use http:// when making the request, however. I'm not sure what the lesson is in using the Wordpress htaccess if the system is supposed to ignore my request and direct me to the front page. The desired effect was dearly_beloved ~> to anythingotherthanthefrontpagesoIcouldseewhatthehtaccessfiledid.php. all the mod rewrite files I know of direct to front page when they don't know how to handle the request.

                  Hi Schwimm,

                  The HTACCESS redirect is set to index.php, but you could set it to whichever processing script you want, so also anythingotherthanthefrontpagesoIcouldseewhatthehtaccessfiledid.php:

                  RewriteRule . /anythingotherthanthefrontpagesoIcouldseewhatthehtaccessfiledid.php [L]
                  In that , you access the $_SERVER global variable; It holds in your example:

                  [REQUEST_URI] => /dearly_beloved

                  You can then use this variable to find in the database the dearly_beloved entry, and show the page that you want.

                    Hi there leatherback and thanks very much for the clarification!

                    I understand now that I need the php script to handle the URI, but am wondering if someone could help me on how to split it, since I'm going to need a couple variables to be passed this way.

                    For instance:

                    /article/dearly_beloved <retrieve an article with that value stored as the permalink
                    /article/dearly_beloved/2 <
                    the same, but the second page of the article

                    /comic/419_work_of_art <~~would grab the comic with this permalink stored in the db

                    What I would like is

                    /$system/$permalink/$page

                    How might I go about splitting the URI up to get all my needed variables?

                      with e.g. explode() you could split the string by slashes. However, it starts to sound like you would be much better of in fancy url rewriting. My mod rewrite skills however are too rusty to really advice you on the exact syntax. Effectively you would like to match against 0 to n instances of (.*)/.

                      Probably best to look at the apache mod rewrite module & examples in the apache manual to get some idea of what is all possible there.

                        Thanks very much for your help. I'm currently playing with:

                        /* Let's build a nifty little SEO URL system. */
                        $uri_element = explode("/", $_SERVER['REQUEST_URI']);
                        $system=$uri_element[1];
                        $permalink=$uri_element[2];
                        $page=$uri_element[3];

                        But haven't tried enough things to see what happens when the URI doesn't fit neatly into this format. For instance, Wordpress allows you to retrieve an article either via the friendly URL or via ?id=1. I need to goof around with it some until I figure out the limitations with the current system.

                          Hi schwin, I thought you might enjoy looking at my .htaccess :

                          RewriteEngine ON
                          RewriteBase /
                          
                          RewriteCond &#37;{REQUEST_FILENAME} -f [OR]
                          RewriteCond %{REQUEST_FILENAME} -d
                          RewriteRule (.+) $1 [L]
                          
                          RewriteRule ^([^/]+)/([^/]+)/(.*)$ index.php?resource=$1&page=$2&qry=$3 [L]
                          RewriteRule ^([^/]+)/([^/]+)/?$ index.php?resource=$1&page=$2 [L]
                          RewriteRule ^([^/]+)/?$ index.php?resource=$1 [L]
                          

                          My urls look like domain.com/blog or domain.com/blog/viewMarch or domain.com/blog/viewMarch/192-great-st.-patricks-day

                            Write a Reply...