Php URL重写和重定向规则
我需要帮助在我自己的URL重写。我的URL结构是 我希望它是什么样子的 到目前为止,我尝试的是在我的.htaccess文件中Php URL重写和重定向规则,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我需要帮助在我自己的URL重写。我的URL结构是 我希望它是什么样子的 到目前为止,我尝试的是在我的.htaccess文件中 ErrorDocument 404 /myproject/notfound.php Options +FollowSymlinks RewriteEngine on RewriteBase /myproject/ RewriteRule ^products/([^/]+)$ products-detail.php?id=$1 [QSA] 上面的规则在结尾没有尾随斜
ErrorDocument 404 /myproject/notfound.php
Options +FollowSymlinks
RewriteEngine on
RewriteBase /myproject/
RewriteRule ^products/([^/]+)$ products-detail.php?id=$1 [QSA]
上面的规则在结尾没有尾随斜杠的情况下运行良好,但我确实希望在结尾有斜杠
更多信息:
如果非重写请求被重定向到重写请求,那就太好了。谢谢:)您需要一个新的重定向规则: ErrorDocument 404/myproject/notfound.php
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /myproject/
RewriteCond %{THE_REQUEST} /products-detail\.php\?id=([^\s&]+) [NC]
RewriteRule ^ products/%1? [R=302,L,NE]
RewriteRule ^products/([^/]+)/?$ products-detail.php?id=$1 [NC,L,QSA]
真棒,真正的快速修复。