我正在重写查询string到美丽的URI,例如: index.php?q=/en/contact成为/en/contact ,所有的作品很好..
# httpd.conf # HANDLE THE QUERY RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
甚至有可能重写单个查询来强制https和强制一切到http ? 我已经尝试了许多不同的方法,通常以无穷循环结束。 我可以写一个插件来做到这一点在PHP中,但认为这将是更有效的处理这在服务器conf。 我会很乐意提供任何build议。
编辑:为了澄清,我想能够重写非SSL http://example.com/index.php?q=/en/contact启用SSL https://example.com/en/contact并且每个不是/en/contact查询都被写入http://example.com/...
htaccess例子:
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^en/contact$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTPS} =on RewriteRule !^en/contact$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
http://domain/en/contact redirect to https://domain/en/contact rewrite to index.php?q = en / contact
http://domain/en/fo重写为index.php?q = en / fo
https://domain/en/foredirect到http://domain/en/fo重写为index.php?q = en / fo
https://domain/en/contact rewrite to index.php?q = en / contact