Tag Info

New answers tagged

2

The problem is that, when you use mod_rewrite in an .htaccess file or a <Directory> section, every successful RewriteRule — even an internal one — causes the request to be restarted internally, and thus the whole rewrite ruleset to be reprocessed. Thus, what's happening is that, when the user visits /page, your internal RewriteRule matches ...


2

I asked this same question on StackOverflow. To get it to work properly, you have to use environment variables: RewriteRule ^page$ /page.html [L,E=LOOP:1] RewriteCond %{ENV:REDIRECT_LOOP} !1 RewriteRule ^page.html$ /page [R=301,L] This is because mod_rewrite does multiple passes through your rules. During the first pass, it sets the environment ...


1

What is the purpose of the redirect? The 301 Canonical The purpose of your redirect is to assure a canonical domain name. As such, the appropriate HTTP response is a 301. By default, many browsers will cache this indefinitely unless you specify a Cache-Control header. The 302 Confusion In the Google reference you provide, they are talking about landing ...


1

The type of redirect you are using is not the problem. 301 redirects are cacheable. In fact they are extremely hard to cache bust. 301 means "permanent" and browsers are very likely to cache 301 redirects with no way with the server to undo one that is already cached. 302 redirects are generally not cached by default unless other headers indicate that ...


0

NON-WWW URLS TO WWW WITH HTTPS USING HTACCESS: You can add the following code to your .htaccess file, you can find it in your website root directory, if you don't find it you can copy this in a text editor and save it as .htaccess, then upload it. p.s.: Make sure that you backup the .HTACCESS file before you proceed. Incorrect codes can lead to 500 ...


1

ok I figured it out RewriteRule ^xy(.*)$ /xy/$1 [R=301,L]


1

Try this: RewriteCond %{REQUEST_URI} !^/xy/ [NC] RewriteCond %{REQUEST_URI} ^/xy(.*)$ [NC] RewriteRule .* http://www.example.org/xy/%1.html [R=301,L] I think should do it. Please let me know and I can update the answer.


8

For your first two rewrites (non-www → www, http → https), the following rule should work: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !=www.example.com [NC] RewriteRule ^(.*) https://www.example.com/$1 [NS,L,R=permanent] Just replace www.example.com with the actual canonical hostname of your site. As for your third ...



Top 50 recent answers are included