url rewriting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqasahmed996
    New Member
    • Jun 2008
    • 160

    url rewriting

    hi to all
    i am facing strange problem hopefully due to my any basic mistake
    when i use code in .htaccess like this
    Code:
    RewriteRule ^d-([A-Za-z0-9-]+)?$ page.php?abc=$1 [NC,L]
    then it will work properly but when i use "/" instead of "-" then page is unable to get effect of my css file

    Code:
    RewriteRule ^d/([A-Za-z0-9-]+)?$ page.php?abc=$1 [NC,L]
    what could be the problem
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    The / char is used in URLs to indicate a directory.

    So, if you rewrite an URL that includes this char to point to a different level of the directory hierarchy, any relative URLs in the file are most likely going to become invalid.

    To avoid this, make sure that all links and external resources use absolute paths.

    An alternative solution would be to catch any CSS file in a RewriteRule and point it to the proper location, but that can cause other, cache related problems.

    Comment

    • DeadSilent
      New Member
      • Feb 2009
      • 8

      #3
      I have a similar question on the same matter. I'm wonder how I can use multiple RewriteRules for different files.. currently I am only able to Rewrite one and if I use any more they either dont work or will cause an error.. here is the code I'm using:

      Code:
      <IfModule mod_rewrite.c>
        Options +FollowSymlinks
        RewriteEngine on  
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ link.php?get=$1 [L,QSA]
      </IfModule>
      I'd like to add the code below for basic actions:

      Code:
      RewriteRule ^(.*)$ index.php?do=$1 [L,QSA]
      then i'd like to have this one

      Code:
      RewriteRule ^(.*)$ index.php?do=$1&search=$2&type=$3&page=$4 [L,QSA]
      which turns out like: /search/$2

      If you could give me some help as well that would be great.. I'm starting to learn this stuff but I still dont get it.. :\

      Thanks guys.

      Comment

      • sohailmarwat
        New Member
        • Mar 2009
        • 1

        #4
        Hi All,
        I am also looking for a solution of URL ReWriting. i am looking to convert the url like urlname/foldername to foldername.ulse rname .

        but when i convert it , it dosnt show the page. please help

        Comment

        • Kelicula
          Recognized Expert New Member
          • Jul 2007
          • 176

          #5
          Originally posted by DeadSilent
          I have a similar question on the same matter. I'm wonder how I can use multiple RewriteRules for different files.. currently I am only able to Rewrite one and if I use any more they either dont work or will cause an error.. here is the code I'm using:

          Code:
          <IfModule mod_rewrite.c>
            Options +FollowSymlinks
            RewriteEngine on  
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ link.php?get=$1 [L,QSA]
          </IfModule>
          I'd like to add the code below for basic actions:

          Code:
          RewriteRule ^(.*)$ index.php?do=$1 [L,QSA]
          then i'd like to have this one

          Code:
          RewriteRule ^(.*)$ index.php?do=$1&search=$2&type=$3&page=$4 [L,QSA]
          which turns out like: /search/$2

          If you could give me some help as well that would be great.. I'm starting to learn this stuff but I still dont get it.. :\

          Thanks guys.
          You are searching the URI for the same match on each rewrite rule. So Apache doesn't know which one you wish to match.

          This match is true if the url matches "any" character. One or more times from beginning to end of url.
          RewriteRule ^(.*)$ index.php?do=$1 [L,QSA]

          This one also matches the same criteria.
          RewriteRule ^(.*)$ link.php?get=$1 [L,QSA]

          How are you going to specify when to "do" or "get"?

          Also, the capture only occurs once. So you have not populated $2, $3 etc...
          The last rewrite rule will always fail.
          RewriteRule ^(.*)$ index.php?do=$1 &search=$2&type =$3&page=$4 [L,QSA]

          Here's a good article.
          Apache Mod_rewrite

          Comment

          Working...