Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

javascript - 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

question from:https://stackoverflow.com/questions/66058987/dynamic-generated-folder-redirect-to-php-file-in-htaccess

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...