| ||||
| If you don't know what .htaccess is then don't mess with it. Make a file called .htaccess on your server or make a file called htaccess.txt on your computer and edit it and then upload it to your server via FTP in ascii mode. Redirecting a single page: This will redirect /oldpage.html to newpage.html. It will not affect any other files. Code: Redirect 301 /oldpage.html http://www.example.com/newpage.html This will redirect the whole site to your new URL. It will work on all files. Code: Redirect 301 / http://www.new-site.com/ You should stick with either site.com or www.site.com for SEO purposes. And also if you have cookies on your site. For example if you have a login/logout page. This code will redirect visitors to site.com from www.site.com. Code: Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L] This code forces www in front of your URL. So it will show up like www.site.com Code: Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301] This is for SEO purposes. Sometimes search engines think that its duplicate content. This will also redirect site.com/folder/index.php to site.com/folder Code: Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3, 9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] Code: # If the hour is 16 (4 PM) Then deny all access
RewriteCond %{TIME_HOUR} ^16$
RewriteRule ^.*$ - [F,L] This is useful for web development. If you're making a site and want only yourself to see the site then you could use this code. Code: AuthUserFile /home/www/site1-passwd AuthType Basic AuthName MySite Require valid-user Allow from 172.17.10 Satisfy Any Code: # A (partial) domain-name Allow from 10.1.0.0/255.255.0.0 # Full IP address Allow from 10.1.2.3 # More than 1 full IP address Allow from 192.168.1.104 192.168.1.205 # Partial IP addresses # first 1 to 3 bytes of IP, for subnet restriction. Allow from 10.1 Allow from 10 172.20 192.168.2 # network/netmask pair Allow from 10.1.0.0/255.255.0.0 # network/nnn CIDR specification Allow from 10.1.0.0/16 # IPv6 addresses and subnets Allow from 2001:db8::a00:20ff:fea7:ccea Allow from 2001:db8::a00:20ff:fea7:ccea/10
__________________ |
![]() |
| Bookmarks |
| Thread Tools | |
| |