Access til sider uden for WordPress

WordPress har masser af muligheder for justere hvem der kan se posts/pages, men sider uden for WordPress er tilgængelig for alle.

Jeg vil gerne give access til mine gamle WEB-sider, men ikke offentligt, i første omgang er adgang for registrerede brugere nok (Der er ikke så mange).

En diskussion på  http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in overbeviste mig om at det kunne lade sig gøre, så jeg gik igang.

På min gamle WEB-site havde jeg i min vished startet alle directories med stort, noget jeg siden har fortrudt, men det viste sig smart lige her.  Derudover var alle billeder pakket ind i et php-script /pics/index.php som engang i tidernes morgen, hvor der var plads problemer på min WEB-server, kunne hente billeder fra en anden server.  Under WordPress bruger jeg Permalink til at identificere posts/pages så alle URL-er er med småt.

En simple måde til at se forskel på sider i og uden for WordPress, er at se om stedet starter med småt eller stort. Adgang til WEB-træet kontrolleres af .htaccess, tilføjer vi et par liner til den kan vi sende de gamle sider gennem et php-script.
[code]]czo4MjpcIlJld3JpdGVSdWxlIF5bQS1aXSBpZl9sb2dnZWRfaW4ucGhwIFtMXQ0KUmV3cml0ZVJ1bGUgXnBpY3MgIGlmX2xvZ2dlZF97WyYqJl19aW4ucGhwIFtMXQ0KXCI7e1smKiZdfQ==[[/code]Selve php-scriptet ser således ud:
[code]]czozMTg1OlwiPD9waHANCi8qDQogKiBpZl9sb2dnZWQtaW4ucGhwDQogKg0KICogUHJvdGVjdCBmaWxlcyB1bnJlbGF0ZWQgdG8gd297WyYqJl19cmRwcmVzcyB3aXRoIGxvZ2luIGZyb20gd29yZHByZXNzDQogKg0KICogb2xkd2ViIGNvbnRhaW5zIGEgb2xkIG9ubW9kaWZlZCBXRXtbJiomXX1CLXNpdGUgYWxsIHRvcCBsZXZlbCBzdGFydCB3aXRoIGEgYSBDQVBJVEFMIGxldHRlcg0KICogcGljdHVyZXMgd2VyZSBzZXJ2ZWQge1smKiZdfXVzaW5nIGEgcGhwLXNjcmlwdCBpbiAvcGljcy9pbmRleC5waHAsIGJhcmVib25lIGltcGx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lcnZlIHRoZSBmaWxlDQpyZWFkZmlsZSggJGZpbGUgKTsNCg17WyYqJl19ClwiO3tbJiomXX0=[[/code]
Husk også en .htaccess som forbyder adgang i oldweb

Print Friendly, PDF & Email
This entry was posted in Web, Wordpress. Bookmark the permalink.

One Response to Access til sider uden for WordPress

  1. Pingback: Billeder fra den gamle WEB | Peter Lorenzen

Comments are closed.