动态生成的文件夹重定向到 htaccess 中的 Php 文件
Dynamic Generated Folder Redirect to Php file in htaccess
我正在这个动态“产品”文件夹上生成一个动态页面。
工作正常 category/product/heading-1
当我只访问 category/product/
文件夹时,它显示错误
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]
如何将 category/product/
重定向到 exmple.com/category/product.php
根据您展示的示例,请您尝试以下操作。将 htaccess 文件放在类别文件夹中,并确保在测试 URL 之前清除浏览器缓存。此外,您的 url category/product 没有任何进一步的路径,因此没有任何内容可以作为查询字符串传递,因此我已将其从下面的第二条规则中删除。
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/([\w-]+)/?$ product.php?u= [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/?$ product.php [NC,L]
我正在这个动态“产品”文件夹上生成一个动态页面。
工作正常 category/product/heading-1
当我只访问 category/product/
文件夹时,它显示错误
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]
如何将 category/product/
重定向到 exmple.com/category/product.php
根据您展示的示例,请您尝试以下操作。将 htaccess 文件放在类别文件夹中,并确保在测试 URL 之前清除浏览器缓存。此外,您的 url category/product 没有任何进一步的路径,因此没有任何内容可以作为查询字符串传递,因此我已将其从下面的第二条规则中删除。
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/([\w-]+)/?$ product.php?u= [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/?$ product.php [NC,L]