Forum Moderators: phranque
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /index.php?pageid=$1 [L]
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} GET
RewriteCond %{REQUEST_URI} (grilling_menu¦buffet_menu)\.html
RewriteRule ^(.*)$ [domain-name.com...] [L,R301]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} GET
RewriteCond %{REQUEST_URI} !(grilling_menu¦buffet_menu)\.html
RewriteRule ^(.*)$ [domain-name.com...] [L,R301]
The 2 urls are
www.domain-name.com/buffet_menu.html
www.domain-name.com/grilling_menu.html
Which are being rewritten from the first rewrite rule that looks like this:
index.php?pageid=grilling_menu
index.php?pageid=buffet_menu
I only want the https on the 2 urls above and not on the rest of the site. Can someone point me in the right direction on how to get this to work?
Thanks,
Itworx4me
A URL 'exists' as soon as you create a link pointing to that resource. The solution is to link to the content with the correct protocol, domain name, and filepath within that link.
Anything else involving redirects should purely be for preventing direct access to the same content via a non-canonical URL.
Note that you should list your rewrite after the redirects. This is a crucial step.
RewriteEngine on
#
RewriteCond %{HTTPS} ^off$
RewriteCond %{REQUEST_METHOD} ^(GET¦HEAD)$
RewriteRule ^((grilling¦buffet)_menu\.html)$ https://www.example.com/$1 [R=301,L]
#
RewriteCond %{REQUEST_URI} !^/(grilling¦buffet)_menu\.html$
RewriteCond %{HTTPS} ^on$
RewriteCond %{REQUEST_METHOD} ^(GET¦HEAD)$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
RewriteRule ^([^/.]+)\.html$ /index.php?pageid=$1 [L]
Important: Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
[edit] Corrected as noted below. [/edit]
[edited by: jdMorgan at 4:08 am (utc) on Feb. 3, 2009]
[Mon Feb 2 19:25:38 2009] [alert] [client ****************] /home/****************/public_html/.htaccess: RewriteRule: unknown flag 'R301'\n
[Mon Feb 2 19:25:38 2009] [alert] [client ****************] /home/****************/public_html/.htaccess: RewriteRule: unknown flag 'R301'\n
...
[Mon Feb 2 19:15:05 2009] [alert] [client ****************] /home/****************/public_html/.htaccess: RewriteRule: unknown flag 'R301'\n
[Mon Feb 2 19:15:05 2009] [alert] [client ****************] /home/****************/public_html/.htaccess: RewriteRule: unknown flag 'R301'\n
Thanks,
Itworx4me
[edited by: jdMorgan at 4:09 am (utc) on Feb. 3, 2009]
I'd be looking for a 'third party' in this situation... Make sure you don't have any redirects set up using your "control panel" that would interfere with these rules.
Jim
What happens if you change the link to https://www.yoursite.com/buffet_menu.html and click it.
Does it stay at the right location as reflected in the browser URL bar?
You'll also need Live HTTP Headers for Firefox to further diagnose the problem.
In addition, I did forget to remind you to completely flush your browser cache before testing any new server-side code. If you don't, your browser may continue to show you previously-cached pages and responses until the requested resource's expiry time is reached, or until the stale browser cache entry is overwritten by a newer cache entry -- either from your own site or from another.
It's possible there's an error in the code as a result of transliteration from the posts here. But it's not highly likely, and the code itself is simple and straightforward. As posted, the internal /index.php filepath cannot be revealed by a redirect from any of the rules, which is why I'm looking for an "outside agent" here.
It may be helpful to comment-out all of these rules, and then un-comment and test them one at a time.
If you continue to have problems, then feel free to re-post the code exactly as it appears on your server, changing only the domain to "example.com".
Jim
I have narrowed it down to this code.
RewriteCond %{REQUEST_URI} !^/(grilling¦buffet)_menu\.html$
RewriteCond %{HTTPS} ^on$
RewriteCond %{REQUEST_METHOD} ^(GET¦HEAD)$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
With this code being commented out the urls go to https. So something in the code above seems to be the issue. Just don't know what part of code it doesn't like.
Thanks,
Itworx4me
Thanks,
Itworx4me
Try changing the first RewriteCond line of that code block to:
RewriteCond %{THE_REQUEST} !^[A-Z]+\ /(grilling¦buffet)_menu\.html\ HTTP/ Since THE_REQUEST is the request header sent by the client, this RewriteCond can't be fooled by a subsequent internal rewrite.
Jim