.htaccess in Subfolder not working


Give this a try:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /coupon/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) stores.php?store_slug=$1 [L]

There should no spaces between ! and -f/d.

Keep in mind that the above rule is only to make http://localhost/coupon/url work, as it will internally redirect any requests from the coupon folder to the stores.php file.

As an additional note, for the CSS, JS, Images, you will need to use absolute path, as using the relative path will assume that the CSS, JS and Images are inside the coupon folder.

So if you had it like this css/my.css it will think it is inside coupon/css/my.css so you need to use it as http://yourdomain.com/css/my.css to avoid that.

And if you place a / after the URL it will it will think that's the folder so it would go like this coupon/flipkart/css/my.css.

Author by


Updated on June 04, 2022


  • user2782183
    user2782183 7 months

    I have a url Like


    I want to change it like this


    I tried with this code

    RewriteEngine on
    RewriteBase /coupon/
    RewriteCond %{REQUEST_FILENAME} ! -f
    RewriteCond %{REQUEST_FILENAME} ! -d
    RewriteRule (.*) stores.php?store_slug=$1

    but its not working with the above mentioned .htaccess code am getting 500 internal server error. I am using this .htaccess file in sub folder ie coupon

    can anybody check where am doing wrong ?