In the .htaccess example below, if someone types in a URL like the following...
http://mysite.com/ricks-motorcycles
...it will automatically load the page from x.com's subdirectory under public_html called "ricks-motorcycles". This technique is called Proxy Throughput .
RewriteEngine On
RewriteRule ^ricks-motorcycles/(.*)$ http://x.com/ricks-motorcycles/$1 [P,L]
This is great, but how do I handle two other situations:
(1) Someone wanting https instead of http.
(2) Someone wanting...
http#//ricks-motorcycles.mysite.com/
...instead of...
http#//mysite.com/ricks-motorcycles/
(Switch # with : above because StackOverflow was blocking me from posting.)
You can qualify your rewrites with a RewriteCond
:
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^ricks-motorcycles/(.*)$ https://example.com/ricks-motorcycles/$1 [P,L]
RewriteCond %{HTTP_HOST} =ricks-motorcycles.mysite.com
RewriteRule ^(.*)$ http://example.com/ricks-motorcycles/$1 [P,L]
For more information, see the mod_rewrite documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.