Mobile app version of vmapp.org
Login or Join
Debbie626

: Htaccess results in an Error on http to https change in proxy I am having an issue trying to change my rewrite rule to use https. Before change, I had the following: RewriteEngine On RewriteBase

@Debbie626

Posted in: #Htaccess #ModRewrite

I am having an issue trying to change my rewrite rule to use https.

Before change, I had the following:

RewriteEngine On
RewriteBase /
RewriteRule ^api/(.*)$ example.com/api/ [L,P]


Which redirected all the requests with 'api' to my server.

Now, I've changed http to https:

RewriteEngine On
RewriteBase /
RewriteRule ^api/(.*)$ example.com/api/ [L,P]


And when I am testing this, it throws:


Server error!

The server encountered an internal error and was unable to complete
your request. Either the server is overloaded or there was an error in
a CGI script.

If you think this is a server error, please contact the webmaster.

Error 500


What am I doing wrong here?

My .htaccess is:

Options -Indexes +FollowSymLinks -MultiViews
# BEGIN Expire headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 648000 seconds"
ExpiresByType application/javascript "access plus 648000 seconds"
ExpiresByType application/x-javascript "access plus 648000 seconds"
ExpiresByType text/html "access plus 6000 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>
# END Expire headers

RewriteEngine On
RewriteBase /
RewriteRule ^api/(.*)$ example.com/api/ [L,P]

# external redirect from /example.html to /example
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+([^.]+).html [NC]
RewriteRule ^ /%1/ [R=301,L]

# internal forward from /example/ to //example.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{DOCUMENT_ROOT}/.html -f
RewriteRule ^(.+?)/?$ /.html [L]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Debbie626

1 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley505

This is what works for me..

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ %{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^api/(.*)$ / [R=301,NC,L]


so basically is takes example.com/api and results in example.com but the real location that it loads is in fact otherdomain.com/api
Update: I belive you also want to mask the url, to show example.com and not otherexpample.com.

For masking:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ %{HTTP_HOST}%{REQUEST_URI} [NC]
RewriteRule ^api/(.*)$ / [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme