@@ -1275,43 +1275,49 @@ function rewriteUrls($documentSource) {
1275
1275
$ documentSource = preg_replace ($ in , $ out , $ documentSource );
1276
1276
}
1277
1277
1278
- $ this ->_fixURI ();
1279
1278
return $ documentSource ;
1280
1279
}
1281
1280
1282
- function _fixURI (){
1281
+ function sendStrictURI (){
1283
1282
// FIX URLs
1284
- if ((int )$ this ->documentIdentifier != 0 && $ this ->config ['seostrict ' ]=='1 ' && $ this ->config ['friendly_urls ' ]=='1 ' ){
1285
- if ($ this ->config ['site_status ' ] == 1 ) {
1286
- $ myProtocol = (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == 'on ' ) ? 'https ' : 'http ' ;
1287
- $ parts = explode ("? " , $ _SERVER ['REQUEST_URI ' ],2 );
1288
- $ parts [0 ] = '/ ' .$ _GET ['q ' ];
1289
- $ strictURL = $ this ->toAlias ($ this ->makeUrl ($ this ->documentIdentifier ));
1290
- $ myDomain = $ myProtocol . ":// " . $ _SERVER ['HTTP_HOST ' ];
1291
- $ newURL = $ myDomain . $ strictURL ;
1292
- $ requestedURL = $ myDomain . $ parts [0 ];
1293
-
1294
- if ($ this ->documentIdentifier == $ this ->config ['site_start ' ]){
1295
- if ($ requestedURL != $ this ->config ['site_url ' ]){
1296
- // Force redirect of site start
1297
- // $this->sendErrorPage();
1298
- header ("HTTP/1.1 301 Moved Permanently " );
1299
- $ qstring = isset ($ parts [1 ]) ? preg_replace ("#(^|&)(q|id)=[^&]+# " , '' , $ parts [1 ]) : '' ; // Strip conflicting id/q from query string
1300
- if ($ qstring ) header ('Location: ' . $ this ->config ['site_url ' ] . '? ' . $ qstring );
1301
- else header ('Location: ' . $ this ->config ['site_url ' ]);
1302
- exit (0 );
1303
- }
1304
- }elseif ($ parts [0 ] != $ strictURL && $ this ->documentIdentifier != $ this ->config ['error_page ' ]){
1305
- // Force page redirect
1306
- header ("HTTP/1.1 301 Moved Permanently " );
1307
- $ qstring = preg_replace ("#(^|&)(q|id)=[^&]+# " , '' , $ parts [1 ]); // Strip conflicting id/q from query string
1308
- if ($ qstring ) header ('Location: ' . $ strictURL . '? ' . $ qstring );
1309
- else header ('Location: ' . $ strictURL );
1310
- exit (0 );
1311
-
1312
- }
1313
- }
1314
- }
1283
+ if (empty ($ this ->documentIdentifier ) || $ this ->config ['seostrict ' ]=='0 ' || $ this ->config ['friendly_urls ' ]=='0 ' )
1284
+ return ;
1285
+ if ($ this ->config ['site_status ' ] == 0 ) return ;
1286
+
1287
+ $ scheme = (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == 'on ' ) ? 'https ' : 'http ' ;
1288
+ $ len_base_url = strlen ($ this ->config ['base_url ' ]);
1289
+ if (strpos ($ _SERVER ['REQUEST_URI ' ],'? ' ))
1290
+ list ($ url_path ,$ url_query_string ) = explode ('? ' , $ _SERVER ['REQUEST_URI ' ],2 );
1291
+ else $ url_path = $ _SERVER ['REQUEST_URI ' ];
1292
+ if (substr ($ url_path ,0 ,$ len_base_url )===$ this ->config ['base_url ' ])
1293
+ $ url_path = substr ($ url_path ,$ len_base_url );
1294
+ $ strictURL = $ this ->toAlias ($ this ->makeUrl ($ this ->documentIdentifier ));
1295
+ if (substr ($ strictURL ,0 ,$ len_base_url )===$ this ->config ['base_url ' ])
1296
+ $ strictURL = substr ($ strictURL ,$ len_base_url );
1297
+ $ http_host = $ _SERVER ['HTTP_HOST ' ];
1298
+ $ requestedURL = "{$ scheme }:// {$ http_host }" . $ _SERVER ['REQUEST_URI ' ];
1299
+ $ site_url = $ this ->config ['site_url ' ];
1300
+ if ($ this ->documentIdentifier == $ this ->config ['site_start ' ]){
1301
+ if ($ requestedURL != $ this ->config ['site_url ' ]){
1302
+ // Force redirect of site start
1303
+ // $this->sendErrorPage();
1304
+ $ qstring = isset ($ url_query_string ) ? preg_replace ("#(^|&)(q|id)=[^&]+# " , '' , $ url_query_string ) : '' ; // Strip conflicting id/q from query string
1305
+ if ($ qstring ) $ url = "{$ site_url }? {$ qstring }" ;
1306
+ else $ url = $ site_url ;
1307
+ $ this ->sendRedirect ($ url ,0 ,'REDIRECT_HEADER ' , 'HTTP/1.0 301 Moved Permanently ' );
1308
+ exit (0 );
1309
+ }
1310
+ }elseif ($ url_path != $ strictURL && $ this ->documentIdentifier != $ this ->config ['error_page ' ]){
1311
+ // Force page redirect
1312
+ //$strictURL = ltrim($strictURL,'/');
1313
+ if (!empty ($ url_query_string ))
1314
+ $ qstring = preg_replace ("#(^|&)(q|id)=[^&]+# " , '' , $ url_query_string ); // Strip conflicting id/q from query string
1315
+ if ($ qstring ) $ url = "{$ site_url }{$ strictURL }? {$ qstring }" ;
1316
+ else $ url = "{$ site_url }{$ strictURL }" ;
1317
+ $ this ->sendRedirect ($ url ,0 ,'REDIRECT_HEADER ' , 'HTTP/1.0 301 Moved Permanently ' );
1318
+ exit (0 );
1319
+ }
1320
+ return ;
1315
1321
}
1316
1322
1317
1323
/**
@@ -1558,7 +1564,7 @@ function executeParser() {
1558
1564
if ($ this ->config ['track_visitors ' ] == 1 ) {
1559
1565
$ this ->invokeEvent ("OnLogPageHit " );
1560
1566
}
1561
-
1567
+ if ( $ this -> config [ ' seostrict ' ]=== ' 1 ' ) $ this -> sendStrictURI ();
1562
1568
$ this ->prepareResponse ();
1563
1569
}
1564
1570
0 commit comments