Results 1 to 3 of 3

Thread: [RESOLVED] Problem loading images, scripts and styles after coding in htaccess file

  1. #1

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    591

    Resolved [RESOLVED] Problem loading images, scripts and styles after coding in htaccess file

    I have addresses like the ones below that are all related to one product :


    http://a.net/skins/them-black/p214-l...titlehere.html
    http://a.net/skins/them-black/p214-l...elongtitlehere
    http://a.net/longtitleherelongtitleh...titlehere.html
    http://a.net/skins/them-black/p214
    http://a.net/them-black/p214
    http://a.net/them-black
    http://a.net/p214
    http://a.net/skins


    I wanted to write a code to process all of them, I used the following method in htaccess file :


    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)$ index.php?keys=$1 [NC,QSA]


    in index.php i used this line in header too :


    <base href="/">


    and some commands for check parameters like as :


    $params = explode( "/", $_GET['keys'] );


    but still my images, styles and script files are not loaded , the reason is clear because it seems that all the requests go to the index.php , how can I solve this problem while I have also used the base commands in header and htaccess.


    If I need to write a better code, what code can cover that example without causing problems in loading the resources files (css,images,js files)?
    Point one: some fools still do not know the reason why cracked software should be used, companies or people who serve the terrorist or Zionist current must be fought, the current era is the era of soft war (the war of ideology and the battle of thoughts) is more important than hard war.
    Point two: foolish thanks are worthless, I am here to shout out the faults so that they will be upset and stop their foolish pride, if you consider yourself strong, stop the death you are heading towards.
    point third: some people or countries in the apocalypse era are just spectators, these are the most worthless creatures.
    Point Four: NSA is one of the largest spy centers in the world : )) .
    Point Five : Age is just a number, sometimes old people are stupider than young people.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    12,062

    Re: Problem loading images, scripts and styles after coding in htaccess file

    Quote Originally Posted by Black_Storm View Post
    ... the reason is clear because it seems that all the requests go to the index.php ...
    Correct. Right now you're turning all requests to index.php with the original request as a query string.

    Quote Originally Posted by Black_Storm View Post
    ... how can I solve this problem while I have also used the base commands in header and htaccess.
    I would setup a RewriteCond so that it excludes your resources files. For example, assuming your file structure looks something like this:
    + /
    + images
    -image1.png
    -image2.png
    + javascript
    -script1.js
    -script2.js
    + css
    -style1.css
    -style2.css


    Then you could add the following to your htaccess:
    Code:
    RewriteEngine on
    RewriteBase /
    
    # exclude requests to the resource directories
    RewriteCond %{REQUEST_URI} !^/images/
    RewriteCond %{REQUEST_URI} !^/javascript/
    RewriteCond %{REQUEST_URI} !^/css/
    
    # redirect all other requests to index.php
    RewriteRule ^(.*)$ index.php?keys=$1 [NC,QSA]
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    591

    Re: Problem loading images, scripts and styles after coding in htaccess file

    thanks for help,i resolved my problem base on this codes :

    htaccess :
    Code:
    RewriteEngine on
    RewriteBase /
    
    <IfModule mod_rewrite.c>
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>


    php :
    Code:
    
    $url=urldecode(ltrim($_SERVER['REQUEST_URI'],'/'));
    $param = explode( "/", $url);
    .
    .
    .


    Point one: some fools still do not know the reason why cracked software should be used, companies or people who serve the terrorist or Zionist current must be fought, the current era is the era of soft war (the war of ideology and the battle of thoughts) is more important than hard war.
    Point two: foolish thanks are worthless, I am here to shout out the faults so that they will be upset and stop their foolish pride, if you consider yourself strong, stop the death you are heading towards.
    point third: some people or countries in the apocalypse era are just spectators, these are the most worthless creatures.
    Point Four: NSA is one of the largest spy centers in the world : )) .
    Point Five : Age is just a number, sometimes old people are stupider than young people.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width