我在应用程序中使用以下.htaccess文件。 到目前为止,一切正常。它提供了SEO友好的URL。 但是我需要在末尾添加.html扩展名。
Options +FollowSymLinks
RewriteEngine On
RewriteBase /Anupama/
RewriteCond %{THE_REQUEST} /product-details(?:\.php)?\?product_id=([^\s&]+)\sHTTP [NC]
RewriteRule ^ Product/%1? [R=302,L,NE]
RewriteCond %{THE_REQUEST} /products(?:\.php)?\?pid=([^\s&]+)\sHTTP [NC]
RewriteRule ^ Categories/%1? [R=302,L,NE]
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# PHP hiding rule
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^Product/([A-Z,0-9-]+)$ product-details.php?product_id=$1 [NC,L,QSA]
RewriteRule ^Categories/([A-Z,0-9-]+)$ products.php?pid=$1 [NC,L,QSA]