38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			ApacheConf
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			ApacheConf
		
	
	
	
	
	
| RewriteEngine On
 | |
| 
 | |
| # -------------------------------------------
 | |
| # 1. Rewrite /blog/<ID> to /blog.php?id=<ID>
 | |
| # -------------------------------------------
 | |
| RewriteRule ^blog/([^/]+)/?$ /blog.php?id=$1 [L,QSA]
 | |
| 
 | |
| # ----------------------------------------------------
 | |
| # 2. Rewrite /lib/* or /blog/* to /error.php?code=404
 | |
| #     with 404 response code (internal rewriting)
 | |
| # ----------------------------------------------------
 | |
| RewriteCond %{REQUEST_URI} ^/(lib|blog)(/.*)?$
 | |
| RewriteRule ^ - [R=404,L]
 | |
| ErrorDocument 404 /error.php?code=404
 | |
| 
 | |
| # ----------------------------------------------------
 | |
| # 3. Custom error handler for all other errors
 | |
| #     Sends proper status code to client
 | |
| # ----------------------------------------------------
 | |
| ErrorDocument 400 /error.php?code=400
 | |
| ErrorDocument 401 /error.php?code=401
 | |
| ErrorDocument 403 /error.php?code=403
 | |
| ErrorDocument 500 /error.php?code=500
 | |
| ErrorDocument 502 /error.php?code=502
 | |
| ErrorDocument 503 /error.php?code=503
 | |
| 
 | |
| 
 | |
| # RewriteEngine On
 | |
| 
 | |
| # ErrorDocument 404 /404.php
 | |
| 
 | |
| # RewriteRule ^b/([0-9]+)$ /blog.php?id=$1 [QSA,L]
 | |
| 
 | |
| # RewriteRule ^/lib - [R=404,L]
 | |
| 
 | |
| # RewriteCond %{REQUEST_FILENAME} !-f
 | |
| # RewriteCond %{REQUEST_FILENAME} !-d
 | |
| # RewriteRule ^.*$ - [R=404,L] |