Search code examples
phpapache.htaccessmod-rewrite

Rewrite rule for subfolder


I have the file structure

index.php
.htaccess
news/index.php
news/.htaccess

First .htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/news/
RewriteRule . /index.php [L]

Second (news/.htaccess)

 RewriteEngine On
 RewriteRule . /index.php

Request http://test.t/news/news/61 the handles first index.php but I need to do it the second

I tried a few more options for the first .htaccess, but it did not succeed


Solution

  • Check your Apache config file (httpd.conf) and make sure the directory you are using for your site includes the AllowOverride option.

    Example:

    <Directory "/Applications/MAMP/htdocs">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>