Mod Rewrite Code Hint

New to mod_rewrite? This is a good place to start.

Mod Rewrite Code Hint

Postby pushpinderbagga » Sat Jun 27, 2009 12:13 pm

I have had the below code in my .htaccess file... could anyone here tell me its purpose ... because I dont know but its should be there for something like for an SEO or what else ?

Code: Select all
RewriteRule ^()$ index.php [NC,L]

RewriteCond %{HTTP_HOST} ^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.my-domain.com/$1 [R=301,L]

RewriteRule ^.+(/images/.+)$ $1 [L]
pushpinderbagga
 
Posts: 36
Joined: Fri May 22, 2009 9:43 pm

Postby richardk » Sun Jun 28, 2009 12:52 pm

Code: Select all
RewriteRule ^()$ index.php [NC,L]

Requests to / will be sent to /index.php.

Code: Select all
RewriteCond %{HTTP_HOST} ^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.my-domain.com/$1 [R=301,L]

Add www. when example.com is requested. FAQ: Forcing www..

Code: Select all
RewriteRule ^.+(/images/.+)$ $1 [L]

Requests to /something/images/more go to /images/more (ie. remove everything before /images). Presumably to fix relative paths, see: FAQ: Relative paths to images, JavaScript, CSS and other external/linked files are broken.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

thanks

Postby pushpinderbagga » Sun Jun 28, 2009 4:03 pm

@richardk

thanks...
pushpinderbagga
 
Posts: 36
Joined: Fri May 22, 2009 9:43 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 81 guests

cron