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

  • neeru_m
    Reply to Need help with logo
    neeru_m
    Thanks Amit for your suggestions. I'll try to improve my logo...
    Today, 04:22 AM
  • AmitMan
    Reply to Music album cover
    AmitMan
    I like the grunge style here. Its a little hard to read at times, especially with the white text on black.

    Nice work, keep up the good stuff!
    Today, 03:29 AM
  • AmitMan
    Reply to Need help with logo
    AmitMan
    I think I see what your trying to do with the underline, but I don't think its working in this case. A simple underline can help to add distance between a title and say a headline and can also make the...
    Today, 03:25 AM
  • AmitMan
    Reply to :::-----What's the graphic standards logo ------:::
    AmitMan
    I've heard of checklists and similar documents used for say ensuring your file is print ready (ensuring all digital images are at least 300dpi, file formats are corrects, appropriate bleeds etc.) but...
    Today, 03:11 AM
  • neeru_m
    Reply to Need help with logo
    neeru_m
    Sorry I just forget to mention. Its a Graphic and Web Design company logo. And the major symbol is a combination of "D" and "L" which is the first letter of company name "Design...
    Today, 02:57 AM
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

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