Manish S
Manish S

Reputation: 111

Dynamic Generated Folder Redirect to Php file in htaccess

I am generating a dynamic page on this dynamic "product" folder.

It is working fine category/product/heading-1


when I am visiting only the category/product/ folder it shows me an error

Not Found The requested URL was not found on this server.

#This file in the category folder
RewriteEngine on
RewriteRule ^product/([0-9a-zA-Z]+)  product.php?u=&1 [NC,L]

how to redirect category/product/ to exmple.com/category/product.php

Upvotes: 1

Views: 70

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133670

With your shown samples, could you please try following. Place your htaccess file inside category folder and make sure you clear your browser cache before testing your URLs. Also your url category/product doesn't have any further path so nothing to pass as query string, hence I have removed it from second rule in following.

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/([\w-]+)/?$  product.php?u=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/?$  product.php [NC,L]

Upvotes: 1

Related Questions