Announcement

Collapse
No announcement yet.

.htaccess rules are not working on Linux

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • .htaccess rules are not working on Linux

    I recently copied a site from my windows machine running WAMP to a Linux machine with a standard LAMP stack.
    .htaccess rules are working fine on my windows machine. But not working on Linux machine.

  • #2
    Can you please post the .htaccess rules?
    What URL are you requesting?

    Comment


    • #3
      Here are the rules of .htaccess file.

      Code:
      RewriteRule ^user2/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?user2=1&class=$1&id=$2&method=$3 [L,QSA]
      RewriteRule ^user2/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?user2=1&class=$1&method=$2 [L,QSA]
      RewriteRule ^(.*)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?class=$1&id=$2&method=$3 [L,QSA]
      RewriteRule ^user2/([A-Za-z0-9-]+)/$ index.php?user2=1&class=$1 [L,QSA]
      RewriteRule ^(.*)/([A-Za-z0-9-]+)/$ index.php?class=$1&method=$2 [L,QSA]
      RewriteRule ^download/([A-Za-z0-9-]+.*) index.php?class=downloads&method=download&target=$1 [L,QSA]
      RewriteRule ^stream/([A-Za-z0-9-+]+.*) index.php?class=downloads&method=download&target=$1 [L,QSA]
      RewriteRule ^(.*)/$ index.php?class=$1 [L,QSA]
      I am requesting URL
      http://DomainName.com/access

      so I have created this rule RewriteRule access index.php?class=access which is working.
      Last edited by Sven; 27-01-17, 03:08 PM.

      Comment


      • #4
        You have at least require a RewriteEngine On directive. However, none of those rules would match a request for http://DomainName.com/access anyway?
        Though, a request for http://DomainName.com/access/ (with a trailing slash) would match the last rule.

        Comment


        • #5
          Originally posted by Nimbus View Post
          You have at least require a RewriteEngine On directive. However, none of those rules would match a request for http://DomainName.com/access anyway?
          Though, a request for http://DomainName.com/access/ (with a trailing slash) would match the last rule.
          I have mentioned the RewriteEngine On at the top.
          Thanks for shed light on the slash issue. How could I modify the last rule to not require a trailing slash?

          Comment


          • #6
            You can change the last rule to make the trailing slash optional:

            RewriteRule ^(.*)/?$ index.php?class=$1 [L,QSA]

            Note the RewriteRule pattern just changed from ^(.*)/$ to ^(.*)/?$ - the ? makes the previous character/group optional. If the trailing slash is not needed at all then remove it.

            Comment

            Working...
            X