Trying to hide the real URL in the bar with .htaccess (silently)

Started by syrinx75, March 20, 2011, 02:11:25 AM

Previous topic - Next topic

syrinx75

Hello,

I'm trying to convert the URLs with .htaccess to hide the real URL.

Every URL of the forum should be converted like that:
https://www.domaine.info/forum/SMF1113/index.php* [nofollow] ==> https://www.domaine.info/index.php* [nofollow]

as examples:
https://www.domaine.info/forum/SMF1113/index.php?board=24.0 [nofollow] ==> https://www.domaine.info/index.php?board=24.0 [nofollow]
https://www.domaine.info/forum/SMF1113/index.php?action=profile [nofollow] ==> https://www.domaine.info/index.php?action=profile [nofollow]

I'm trying the following code without success:

RewriteCond %{HTTP_HOST} ^www\.domaine\.info$
RewriteRule ^(index\.php*)?$ /forum/SMF1113/index.php [L]

RewriteCond %{QUERY_STRING} ^board=([0-9]+)\.([0-9]+)
RewriteRule ^(.*)$ /$1? [L]


Do you know which wording to use? I want silently rewriting. I'm thinking that I'm not far from the solution!

syrinx75

With this this .htaccess:

RewriteCond %{HTTP_HOST} ^www\.domaine\.info$
RewriteRule ^(index\.php*)?$ /forum/SMF1113/index.php [L]


With this, the short URLS are working kike this one:
hxxps:www.domaine.info/index.php?board=24.0

but as soon as I navigate in the forum, the long URL addresses are coming back, like this:
hxxps:http://www.domaine.info/forum/SMF1113/index.php?board=24.0 [nofollow]

How to show only the simplified URL in any case? Thanks a lot.

MrPhil

First, are you producing URLs in SMF that are the "short" form? That is, the URL that users and search engines see shouldn't include the "forum/SMF1113/". That would be in Settings.php. Then, it's easy enough to insert forum/SMF1113/ into any URL.


RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domaine\.info
RewriteRule ^.*$ /forum/SMF1113/$1 [L]

syrinx75

Hello MrPhil,

Where is the menu to change the form into short form?

I made this modification in .htaccess, I got again that:
https://www.domaine.info/forum/SMF1113/index.php?board=23.0 [nofollow]

Is it because I use the forum in SSL?

MrPhil

In Settings.php, if your $boardurl is "http://www.domaine.info/forum/SMF", change it to "http://www.domaine.info" and then make the .htaccess changes.

syrinx75

I did these changes ($boardurl and .htaccess), the connextion page to the forum is no color, no image.

MrPhil

1. Where are your files actually located?
2. What is $boardurl set to? I.e., what URL is used for links, CSS, etc.?
3. What's in your .htaccess?
4. You've cleared your browser cache (or ctrl-F5 force reload of all page files)?

syrinx75

Quote from: MrPhil on March 20, 2011, 04:10:50 PM
1. Where are your files actually located?
2. What is $boardurl set to? I.e., what URL is used for links, CSS, etc.?
3. What's in your .htaccess?
4. You've cleared your browser cache (or ctrl-F5 force reload of all page files)?

1) actual location: /public_html/forum/SMF1113/index.php
2) with your help, I've put:  $boardurl = 'http://www.domaine.info [nofollow]' but only the following one is running well: $boardurl = 'http://www.domaine.info/forum/SMF1113' [nofollow]
3) the .htaccess in public-html:

RewriteEngine on

#to force https
SSLOptions +StrictRequire
SSLRequireSSL
ErrorDocument 403 /err_redirect.php
AuthName "public"
AuthUserFile "/home7/domaine/.htpasswds/public_html/passwd"
AuthType Basic
require valid-user
<Files /err_redirect.php>
AuthType none
</Files>

RewriteCond %{HTTP_HOST} ^(www\.)?domaine\.info
RewriteRule ^.*$ /forum/SMF1113/$1 [L]


4) To test, I close and open always Firefox to refresh the browser cache.

Please notice that the forum is running in https. Thanks.

MrPhil

Oops, that last line should be
RewriteRule ^(.*)$ /forum/SMF1113/$1 [L]
You want to capture the URI into $1.

The intent here is to have all your URLs produced by SMF links and so on be without /forum/SMF1113, and for .htaccess to add that back in to get the real URL (without displaying it to the user).

Give that a try and see if it works. There shouldn't be any difference between how http: and https: behaves. Do you really need to run a forum on https?

syrinx75

I have to keep https. Sorry.

I changed like you wrote. I get the same result: I can see the real URL in the bar: https://www.domaine.info/forum/SMF1113/index.php?blablabla [nofollow]

Someone told me that I want to do is not possible with Rewrite. SMF should rewrite the URL like I want. Do you agree?

Arantor

I don't think anyone told you it wasn't possible to do with rewrite, but you have been advised more than once that it's not the greatest idea in the world, especially given the extra load it generates, not to mention complications with either of the 'pretty URLs' mods.
Holder of controversial views, all of which my own.


mashby

Here's a novel idea. Move /forum/SMF1113 to the public root of your webserver?
Always be a little kinder than necessary.
- James M. Barrie

Arantor

Oh, I already suggested that, but apparently that's not what the OP wants to do.
Holder of controversial views, all of which my own.


MrPhil

Well, maybe %{HTTP_HOST} isn't matching your domain because it's HTTPS? Supposedly there is no %{HTTPS_HOST}, but you're welcome to try it if you're desperate. If you have only one domain name in use, you might even be able to drop the RewriteCond line (as it should always match, at least under http: circumstances). Beyond that, I dunno. This stuff has always worked under http:, but maybe https: is a little less forgiving?

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

syrinx75

Quote from: mashby on March 21, 2011, 08:09:35 PM
Here's a novel idea. Move /forum/SMF1113 to the public root of your webserver?

I want to keep clear the root of the domain for an eventual other use.

syrinx75

Quote from: MrPhil on March 21, 2011, 09:20:34 PM
Well, maybe %{HTTP_HOST} isn't matching your domain because it's HTTPS? Supposedly there is no %{HTTPS_HOST}, but you're welcome to try it if you're desperate. If you have only one domain name in use, you might even be able to drop the RewriteCond line (as it should always match, at least under http: circumstances). Beyond that, I dunno. This stuff has always worked under http:, but maybe https: is a little less forgiving?

There are only:
QuoteHTTP_USER_AGENT
HTTP_REFERER
HTTP_COOKIE
HTTP_FORWARDED
HTTP_HOST
HTTP_PROXY_CONNECTION
HTTP_ACCEPT

I don't know what to do.

Advertisement: