Add htaccess for clean URLs
Also rename main files to index.php to avoid the need for custom directory indices. Attached is a script for testing.
This commit is contained in:
29
.htaccess
29
.htaccess
@@ -1,3 +1,26 @@
|
||||
ErrorDocument 404 /main.php?page=404
|
||||
DirectoryIndex mainkrk.php main.php index.php start.html index.html
|
||||
Options -Indexes
|
||||
ErrorDocument 404 /index.php?page=404
|
||||
|
||||
# Redirect old URLs to new ones
|
||||
RewriteCond &%{QUERY_STRING} &lang=(cs|en|de) [NC]
|
||||
RewriteCond %1@&%{QUERY_STRING} (cs|en|de)@.*&page=([^&]+) [NC]
|
||||
RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1/%2.html [R=301,QSD,L,nosubreq]
|
||||
|
||||
RewriteCond &%{QUERY_STRING} &page=([^&]+) [NC]
|
||||
RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1.html [R=301,QSD,L,nosubreq]
|
||||
|
||||
RewriteCond &%{QUERY_STRING} &lang=(cs|en|de) [NC]
|
||||
RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1/ [R=301,QSD,L,nosubreq]
|
||||
|
||||
# Canonization
|
||||
RewriteRule ^cs(?:/(.*))?$ /krk/$1 [R=301,L]
|
||||
RewriteRule ^(en|de)$ /krk/$1/ [R=301,L]
|
||||
RewriteRule ^(mainkrk|index|print).php$ /krk/ [R=301,L]
|
||||
|
||||
### Fall back to loading pages through our “CMS”
|
||||
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
|
||||
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
|
||||
RewriteRule ^(en|de)/$ /krk/index.php?lang=$1 [END]
|
||||
RewriteRule ^(en|de)/(.+)\.html$ /krk/index.php?page=$2&lang=$1 [END]
|
||||
RewriteRule ^(.+)\.html$ /krk/index.php?page=$1 [END]
|
||||
RewriteRule ^(en|de)/(.+)/$ /krk/index.php?page=$2&lang=$1 [END]
|
||||
RewriteRule ^(.+)/$ /krk/index.php?page=$1 [END]
|
||||
|
||||
Reference in New Issue
Block a user