VLS
VLS

Reputation: 445

Htaccess issue which can't figured it out

I have strange problem with .htaccess and urls. I have this in htaccess

<IfModule mod_rewrite.c>
       RewriteEngine On 
       RewriteBase /sitesubfolder/

       RewriteRule ^test$ pages/test.php
</IfModule>

this on my href link

<a href="test/"> Link </a>

The site is in subfolder not in root dir and the path is /var/www/www/site/ When I go to the site url and click on the Link page refreshed but is staying on same page. If I click again url become site.com/test/test/test.. every new click on Link is just placing one more /test/ to the page.

Server is nginx if is matter.

I've added this to site.conf

server {

     root   /var/www/www/site/;
     index  index.php index.html;

     location / {
        try_files $uri $uri/ /index.php?$query_string;
     }
   ....
}

But still same (I've reloaded nginx also)

Upvotes: 1

Views: 23

Answers (1)

Richard Smith
Richard Smith

Reputation: 49782

From your existing .htaccess file, it seems to me that the problem can be summarised as follows:

The document root is /var/www/www/site, there is a sub-folder sitesubfolder below it, containing another subfolder called pages.

When within the URI /sitesubfolder, the relative link test/ (which the absolute link /sitesubfolder/test/ should invoke /var/www/www/site/sitesubfolder/pages/test.php

There are many ways to achieve this, for example:

rewrite ^/sitesubfolder/test/$ /sitesubfolder/pages/test.php last;

See this document for more.

Upvotes: 1

Related Questions