Whooked

Go Back   Whooked > Web Development > Web Dev

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old March 22nd, 2008
th13rteen's Avatar
Proud Whooked Addict
 
Join Date: Sep 2007
Posts: 2,283
Thanks: 14
Thanked 41 Times in 31 Posts
th13rteen is on a distinguished road
Send a message via MSN to th13rteen
Default .htaccess Codes

If you don't know what .htaccess is then don't mess with it. I think you'll know what to do after reading this little tutorial.

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
Redirecting the whole site:

This will redirect the whole site to your new URL. It will work on all files.
Code:
Redirect 301 / http://www.new-site.com/
Redirect www to non-www version of site:

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]
Redirect non-www to www version of site:

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]
Redirect site.com/index.php to site.com

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]
Block access to site during a certain time:

Code:
# If the hour is 16 (4 PM) Then deny all access 
RewriteCond %{TIME_HOUR} ^16$    
RewriteRule ^.*$ - [F,L]
Allow from a IP, and require password for other IPs:

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
Examples of allow directive:

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
__________________
Reply With Quote
  #2 (permalink)  
Old March 22nd, 2008
VuDo0's Avatar
Member
 
Join Date: Jan 2008
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
VuDo0 is on a distinguished road
Default

Nice I use a lot .htaccess Codes
__________________



PLEASE CREATE MIRRORS FOR WHAT YOU TAKE!


Reply With Quote
  #3 (permalink)  
Old May 10th, 2008
Member
 
Join Date: Apr 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
kepler001 is on a distinguished road
Default

nice code thankssss
Reply With Quote
  #4 (permalink)  
Old May 10th, 2008
Banned
 
Join Date: Apr 2008
Location: 3rd World
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Kraiser is an unknown quantity at this point
Send a message via AIM to Kraiser Send a message via MSN to Kraiser
Default

the code really helps..
Reply With Quote
  #5 (permalink)  
Old May 11th, 2008
sanjiv's Avatar
Web Designer
 
Join Date: Sep 2007
Posts: 1,349
Thanks: 62
Thanked 16 Times in 14 Posts
sanjiv is on a distinguished road
Default

nice
thanks useful
Posted via Mobile Device
Reply With Quote
  #6 (permalink)  
Old May 13th, 2008
Tyler's Avatar
Member
 
Join Date: Feb 2008
Location: Girls
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Tyler is on a distinguished road
Send a message via MSN to Tyler Send a message via Yahoo to Tyler
Default

Thanks for this, I know most of these but They get really hard to remember after awhile.

I didn't know how you could make it add www. to the beginning to a url.
Reply With Quote
  #7 (permalink)  
Old May 24th, 2008
Member
 
Join Date: May 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
lineage2peru can only hope to improve
Default

wow thnaks for the info
Reply With Quote
  #8 (permalink)  
Old May 28th, 2008
Banned
 
Join Date: Mar 2008
Posts: 95
Thanks: 0
Thanked 1 Time in 1 Post
Rico760 can only hope to improve
Default

i was looking for this
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:48 PM.