RewriteEngine on
RewriteRule ^page/?$ page.php [L]

This eventually ends up matching the url www.site.com/page// but internally it functions in a different way than www.site.com/page/ since the stylesheets and pictures no more appear correctly. Shall We Be Held doing a problem or perhaps is this just something I have to cope with if I'd rather not undergo lots of trouble?

In my experience it appears enjoy it should only match www.site.com/page or www.site.com/page/

Apache strips the empty path segment. So /path// is treated as /path/. However your browser doesn’t so relative Web addresses are resolved using /path//.

If you wish to take away the multiple slashes, you should use the next rule:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(([^/\ ]+/)*)/+([^\ ]*)
RewriteRule ^ /%1%3 [L,R=301]


Explaination

Despite Apache removes empty path segments internal, the THE_REQUEST atmosphere variable (holding the HTTP request line) stays untouched. Therefore we may use this value to check on for multiple slashes.

  • ^[A-Z]+\ / matches the request method, the next space and also the first slash character from the URI path.
  • (([^/\ ]+/)*) matches all following non-empty path segments (foo/, foo/bar/, foo/bar/baz/, etc.) or free, if you will find none.
  • /+ matches the empty path segments because the character before slash is definitely another slash (begin to see the expressions before).
  • ([^\ ]*) matches the relaxation from the URI (that could contain further empty path segments).

Example: Let us say we request http://example.com/foo/bar//baz, the request line may be like this:

GET /foo/bar//baz HTTP/1.1

The pattern would then match the following:

0: GET /foo/bar//baz
1: foo/bar/
2: bar/
3: baz

Therefore the asked for path /foo/bar//baz could be rerouted to /foo/bar/baz (/%1%3).