.htaccess complex and tricky redirection

本小妞迷上赌 提交于 2019-12-25 02:39:53

问题


I am not expert in .htaccess that my need bit complex and tricky help..!

Here is my current .htaccess and remember i need some .htaccess that can destroy my current .htaccess.

Current .htaccess:

RewriteRule ^join$  https://example.com/internalpath/join/index.php [L,QSA]
RewriteRule ^join/(.*)$ https://example.com/internalpath/join/$1 [L,QSA]

Now my problem:

I want to redirect each and every file and directories to HTTP, except these two:

https://example.com/join/

https://example.com/join

Remember, I want every link on http except this above provided link, other then all files and directories and even files and directories in /join/ or /join will be HTTP, just two links on HTTP, but please it will not destroy the previous written .htaccess.


回答1:


Try this (not tested):

RewriteCond %{REQUEST_URI} !/join/?$ [NC]
RewriteRule ^(.*)$ http://domain.com/internalpath/$1 [R=301,QSA,L]



回答2:


You need these 3 rules:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(join/.+)$ https://%{HTTP_HOST}/internalpath/$1 [R=301,NC,L]

RewriteCond %{HTTPS} off
RewriteRule ^(join)/?$ https://%{HTTP_HOST}/internalpath/$1/index.php [R=301,NC,L]

RewriteCond %{HTTPS} on
RewriteRule !^join http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]


来源:https://stackoverflow.com/questions/22444015/htaccess-complex-and-tricky-redirection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!