Need APACHE SEF help SOLVED MUST READ

5 replies
I don't believe I got this right... Someone please check me on this.
The problem I'm having is that in the root directory of my site I created a folder named 'Graphic_Logo_Design_Artist_Gallery'. Inside this there is an '.htaccess' file containing the following:

<Files category>
*ForceType application/x-httpd-php
</Files>

Am I wrong in assuming that if I now create a file named 'category' without the '.php' extension at the end and that file simply contains:

<?php
include('category.php');
?>

Should I not be able to access the content on 'category.php' simply by going to the following link?:

http://www.mysite.com/Graphic_Logo_D...llery/category
#apache #htaccess #php #sef
  • Profile picture of the author SteveSRS
    it should work.. however it depends on your htaccess settings.. it might not overwrite settings from htaccess in root file

    I'm just a bit in a hurry so I don't have time to check but I don't believe that '*' should be there.... the line you wrote basically means.

    Every requested file by a browser is parsed through php on your server.
    {{ DiscussionBoard.errors[7449215].message }}
    • Profile picture of the author PHPSpaZ
      I took out the '*' and now I can directly access other pages in the directory. Thanks on that. I still cant seem to access the other pages though. The real link is:
      http://producedbydeuce.com/Graphic_L...llery/category
      Where :
      http://producedbydeuce.com/Graphic_L...rtist_Gallery/
      is where this application resides.
      T-shirt Printing CD Duplication Replication copying Poster & flyers
      Contains an installation of cubecart using the sef mod. Would the htaccess file from that directory be affecting this directory's hta file?
      {{ DiscussionBoard.errors[7449480].message }}
      • Profile picture of the author PHPSpaZ
        UPDATE:::

        I changed the hta file to look like this:

        Options +FollowSymLinks
        RewriteEngine on
        RewriteRule ^(category)-(.*).html category.php?cid=$1

        and the link is now:

        http://producedbydeuce.com/Graphic_L...ery/category-1

        But now when it takes me to the page it is titled category.html and it doesn't load, instead it triggers a download.
        {{ DiscussionBoard.errors[7450687].message }}
        • Profile picture of the author PHPSpaZ
          The problem has been solved. After replacing the following line in the 'Graphic_Logo_Design_Artist_Gallery' directory's '.htaccess' file with the line below it the redirect started working but the page was downloading instead of running the php script inside.

          Options +FollowSymLinks
          RewriteEngine on
          RewriteRule ^(category)-(.*).html category.php?cid=$1

          Replaced with:

          Options +FollowSymLinks
          RewriteEngine on
          RewriteRule ^(category) category.php

          The problem with that was the root of the site also had a '.htaccess' file. This file contained the line:

          ForceType application/x-httpd-php

          I commented that out which stopped my pages from downloading once I hit them.

          NOW I was getting to the correct page so I wanted to see if I could pass a var. SO:

          Options +FollowSymLinks
          RewriteEngine on
          RewriteRule ^(category) category.php

          Became:

          Options +FollowSymLinks
          RewriteEngine on
          RewriteRule ^(category)-(.*) category.php?cid=$2

          Now I could pass a variable like this:

          ....site.com/category-1

          This would load 'category.php' and pass it a var named 'cid' that I could use as normal. For example echo it out, or use it in a query to grab info from a database. BUT! My category.css page (linked to 'category.php') was not working. I had a five minute maniacal laughing/crying fest and then it hit me. I needed to rename my '.css' file to something other than 'category'.

          Regex via Apache looks at ANY link internal or external. Remember that when you are putting links into your pages or linking style sheets. If you write a general rule like the one above, the server will use that rule on ANY LINK contained in ANY FILES of that directory.

          I hope I explained this well enough for it to help someone. I spent two days beating my head against a wall with this stuff and I would hate to see anyone going through this... If you have questions PM me and I'll get back to you within 1 day.
          {{ DiscussionBoard.errors[7451079].message }}
  • Profile picture of the author SteveSRS
    Hey phpspaz,

    hehe I'm just now really reading your nickname funny
    Glad you solved the problem.. I've had those days too as times .htaccess can be real head breaker especially because it is pretty much impossible to debug.. its just trial-n-error.

    I saw you already noticed this but I wrote my reply wrong 'that '*' should be' should have been: 'that '*' should NOT be', of course

    Just my extra 2 cents try to keep all htaccess rules just in the root htaccess file.
    Often is not necessary to make extra .htaccess files in subdirs. This is only useful when you have a lot of rules for a sub folder (which are not useful for the rest of the site, it makes page a bit faster)
    {{ DiscussionBoard.errors[7453352].message }}

Trending Topics