Home Exclude a URL from mod_rewrite rule - stop redirect to home page
Reply: 0

Exclude a URL from mod_rewrite rule - stop redirect to home page

user1015
1#
user1015 Published in July 21, 2018, 9:53 am

I need a mod_rewrite to redirect all http requests to https, but I want do exclude one URL

Here's what I have so far in .htaccess file.

# force https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/template/.*$ [NC]
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,QSA]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

http://example.com/template/` should not be redirected. But it is being redirected to the home page.

http://example.com/template/
301 Moved Permanently
https://example.com/index.php
301 Moved Permanently
https://example.com/
200 OK

Can anyone figure out why it's causing a redirect to the home page?

Thank you!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311983 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO