Announcement Announcement Module
Collapse
No announcement yet.
Apache Configuration Help Page Title Module
Move Remove Collapse
Search Search Module
Collapse

Advertisement Advertisement Module
Collapse

Featured Images Featured Images Module
Collapse

Mediabistro Creative Sites Mediabistro Creative Sites Module
Collapse
Latest Topics Latest Topics Module
Collapse

  • <b>
    Comment on Anybody use a Mac Mini?
    <b>
    Right now, at work, I'm using an early 2011 MacBook Pro. It's had no problems at all. I'll likely get a new one early next year, but I'm in no hurry because I don't want to give up the 17-inch display....
    Today, 09:47 PM
  • iyiyi
    Reply to Anybody use a Mac Mini?
    iyiyi
    Overall I haven't really ever had any problems with macs either. Basically just the grpahics card problems I've been talking about. And the 2011 MBP is notorious for them (which is what I have now)....
    Today, 09:40 PM
  • <b>
    Reply to Anybody use a Mac Mini?
    <b>
    This is a puzzling discussion because the things described run counter to my experiences.

    I've been buying Macs since 1984, and have probably owned, maybe, a couple dozen of them. Also during...
    Today, 09:23 PM
  • MeadowlarkGraph
    Reply to Infographics...struggle
    MeadowlarkGraph
    Okay, first attempt at less boring. More variation in text size and background, some different images, shadows. Tried a few different layouts but nothing was hitting me. I actually like "hospice...
    Today, 09:13 PM
  • iyiyi
    Reply to Anybody use a Mac Mini?
    iyiyi
    They are what I used before my mpb. They always had issues. The graphics cards would get screwed up and the screens would freeze (like my mpb is now doing), they were for some reason slower than other...
    Today, 08:53 PM
Advertisement Advertisement Module
Collapse

Sponsors Sponsors Module
Collapse

X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Apache Configuration Help

    This is a shot in the dark, but sure some of you have dealt with this same problem.

    Would it be possible to create a rewrite rule that would remove index.php from the typical /index.php/controller PHP MVC app route?

    What I have: /index.php/blogs/1/20/

    What I would like: /blogs/1/20/

    So I would ideally like all my paths to look like:

    www.whatever.com/blogs/1/20/
    www.whatever.com/user/3/
    www.whatever.com/blog-entry/1/3/10/

    I think you get the idea.

    The application is responsible for breaking up all the paths so all I need is a way to route everything without using site.com/index.php/x/y/z/ , but rather site.com/x/y/z/.

    any help appreciated as I'm not very familiar with apache configuration.

  • #2
    Possible? Yes, but probably not a good idea. Or, at least, a very complicated to pull off one.

    Apache's mod rewrite rules are regular expressions. So you'll need to produce a regular expression - or set of regular expressions - that will rewrite the URL to go to the right page (which is easy) but not rewrite the URLs for your images/CSS/Javascript/anything else that isn't a PHP page (not so easy). Including the index.php in the URL makes it easier to identify the URLs for rewriting in your regex. But, as long as there's some systematic way to identify the URLs to rewrite, it can be done.

    Comment


    • #3
      tZ look up .htaccess SEFs and .htacess rewrite and if you are using a blog application put that in there too.

      .htaccess is a public text file that overwrites the apache config file without actually doing anything to apache core. Great method so that you won't have to worry about what you did when upgrading.

      The htaccess rewrite command will get you where you need to be. This is from a quick google that looks ok.

      http://www.yourhtmlsource.com/sitema...rewriting.html

      Jade

      Comment


      • #4
        Here's the core link.
        http://httpd.apache.org/docs/trunk/howto/htaccess.html

        http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
        Last edited by Drazan; 06-16-2009, 10:32 PM.

        Comment


        • #5
          I'm not positive, but I'm thinking something along these lines would work. The only directories at the root of the site are include,vendor and img. So if the beginning doesn't matches any of those rewrite perhaps?

          Code:
          <IfModule mod_rewrite.c>
          
          RewriteEngine on
          
          RewriteRule ^.*?(?<!index\.php|include|img|vendor)/(.*?)$ /index.php/$2 [L]
          
          </IfModule>
          Last edited by tZ; 06-16-2009, 11:12 PM.

          Comment


          • #6
            Originally posted by tZ View Post
            I'm not positive, but I'm thinking something along these lines would work. The only directories at the root of the site are include,vendor and img. So if the beginning doesn't matches any of those rewrite perhaps?

            Code:
            <IfModule mod_rewrite.c>
            
            RewriteEngine on
            
            RewriteRule ^.*?(?<!index\.php|include|img/vendor)/(.*?)$ /index.php/$2 [L]
            
            </IfModule>
            Sounds right to me.

            Comment


            • #7
              oh it has been a while ... you are making my brain work tonight.

              Try this if that doesn't work as expected.
              This should remove the index.php from the url entirely. Place the .htaccess file in the same directory as the index.php

              If it drops your site, then remove the .htaccess file.

              And to test that you can actually see the .htaccess file with your ftp. put a blank file in there first.
              Code:
              <IfModule mod_rewrite.c>
              
              RewriteEngine on
              
              RewriteRule ^/([a-zA-Z0-9_-]+)/([0-9]+)/$ index.php/$2/  [R]
              RewriteRule ^/([a-zA-Z0-9_-]+)/([0-9]+)/$ index.php/$2  [QSA,L]
              
              </IfModule>

              Comment


              • #8
                That results in a apache request error (mine not drazan's - at least yet).

                Comment


                • #9
                  no go drazan.

                  404 - not found

                  I haven't used apache to rewrite anything in a couple months so I'm a little rusty myself.

                  The site isn't a blog, but has a blog module so to speak. Those URLs were just examples though.

                  I just need everything to go to the index page unless the beginning of the string is img, vendor, include or index.php.
                  Last edited by tZ; 06-16-2009, 11:43 PM.

                  Comment


                  • #10
                    i'm a novice to regular expressions, having just learned how to write one a couple days ago...but i understood that you had the carrot (^) then two forward slashes, and what you wanted to include between the slashes...

                    so, shouldn't there be an ending slash on that second one?...if not, how come?
                    Monarchs Rule!

                    Comment


                    • #11
                      I had add a line to application code to look for the pathway var, but this is working. I much rather reset path_info after the rewrite, but that doesn't seem possible.

                      Code:
                      <IfModule mod_rewrite.c>
                      
                      RewriteEngine on
                      RewriteCond &#37;{REQUEST_URI} !^/(index\.php|include|vendor|img)
                      RewriteRule .? /index.php?pathway=%{REQUEST_URI} [L]
                      
                      </IfModule>
                      Last edited by tZ; 06-17-2009, 03:53 AM.

                      Comment

                      Mediabistro A division of Prometheus Global Media home | site map | advertising/sponsorships | careers | contact us | help courses | browse jobs | freelancers | content | member benefits | reprints & permissions terms of use | privacy policy Copyright © 2014 Mediabistro Inc. call (212) 389-2000 or email us
                      Working...
                      X