我需要重写部分我的url作为参数和部分路径。是否有可能,如果这样任何人都可以请帮我htaccess重写URL的一部分,并保持原样
更具体我有一个这样的网址:
www.mysite/products/producer:some+producer/category:some+category/color:red,blue,yellow
和我需要的是
www.mysite/products.php/producer:some+producer/category:some+category/color:red,blue,yellow
为了让事情更有趣取决于用户查询路径后www.mysite/products/
可以更短或更长
如果我有恒定数量的参数,我会写这样的东西
RewriteRule ^products/([a-zA-Z-_0-9]+)/([a-zA-Z-_0-9]+)/?$ products.php/$1/$2 [L]
,但由于一些参数的变化,我不知道该怎么办
这是我整个的htaccess到目前为止
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.pl
RewriteRule ^(.*)$ http://www.mysite.pl/$1 [R=permanent,L]
RewriteRule ^products/(.+)/?$ /products.php/$1 [NE,L]
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
AddDefaultCharset UTF-8
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 month"
Header append Cache-Control "public"
</IfModule>
## EXPIRES CACHING ##
虽然你的第一个方法看起来很有前途,但它给了我404错误 – krzysztof
@krzysztof确保你有'选项-MultiViews'启用 –
是我有正确的选项启用,我甚至可以说你的第二个方法是工作 - 它需要一个问题处理htaccess中的每个场景,我在寻找更普遍的东西,因为我在php中更好。 – krzysztof