nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Redirect + Rewrite Problem in Lighttpd Web Server

This is a discussion on Redirect + Rewrite Problem in Lighttpd Web Server within the Web servers forums, part of the Mastering Servers category; Hello guys I just bought a VPS and was using SEO redirects on my e107 but have been forced to ...


Go Back   nixCraft Linux Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 19-05-2008, 12:04 PM
Junior Member
User
 
Join Date: May 2008
OS: CENTOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Lamba is on a distinguished road
Exclamation Redirect + Rewrite Problem in Lighttpd Web Server

Hello guys I just bought a VPS and was using SEO redirects on my e107 but have been forced to use apache which is quite frankly a hog. So when using apache the .htaccess works perfectly but it isn't the case with lighthttpd.

I think it may need converting and I would be so thankful if you could help out

My .htaccess file
Code:
RewriteEngine On

RewriteRule home.html news.php
RewriteRule index.html news.php
RewriteRule index.htm news.php
RewriteRule default.html news.php
RewriteRule default.htm news.php

RewriteBase /

RewriteRule themes.html$ themes.php
RewriteRule themes([0-9]*)\.html(.*) themes.php?start=$1
RewriteRule themes-([0-9]*)\.html(.*) news.php?themepreview.$1
#RewriteRule download/(.+)/$ createzip/download.php?theme=$1

# ===============================================
# NEWS ==========================================
RewriteRule news.html$ news.php
RewriteRule news([0-9]*)-([0-9]*)\.html(.*)$ news.php?$1.$2
RewriteRule news([0-9]*)-([0-9]*)-([0-9]*)\.html(.*)$ news.php?$1.$2.$3
RewriteRule news-i([0-9]*)-([0-9]*)\.html(.*)$ news.php?item.$1.$2
RewriteRule news([0-9]*)\.html(.*)$ news.php?extend.$1
RewriteRule news-c([0-9]*)\.html(.*)$ news.php?cat.$1
RewriteRule news-c([0-9]*)-([0-9]*)\.html(.*)$ news.php?cat.$1.$2

# ==============================================
# DOWNLOADS ====================================
RewriteRule download.html$ download.php
RewriteRule downloads([0-9]*)\.html(.*)$ download.php?view.$1
RewriteRule download([0-9]*)\.html(.*)$ download.php?list.$1
RewriteRule downloads([0-9]*)$ download.php?view.$1
RewriteRule download([0-9]*)$ download.php?list.$1
RewriteRule request([0-9]*)\.html(.*)$ request.php?$1

# ==============================================
# PAGE.PHP =====================================
RewriteRule page.html page.php
RewriteRule page([0-9]*)\.html(.*)$ page.php?$1

#==============================================
# USER.PHP ====================================
RewriteRule user.html user.php
RewriteRule user([0-9]*)\.html(.*)$ user.php?id.$1

# =============================================
# SUBMITNEWS.PHP ==============================
RewriteRule submitnews.html submitnews.php

# =============================================
# CONTACT.PHP =================================
RewriteRule contact.html contact.php

# =============================================
# COMMENTS ====================================
RewriteRule comment-n([0-9]*)\.html(.*)$ comment.php?comment.news.$1
RewriteRule reply-n([0-9]*)-([0-9]*)\.html(.*)$ comment.php?reply.news.$1.$2
RewriteRule reply-d([0-9]*)-([0-9]*)\.html(.*)$ comment.php?reply.download.$1.$2

# =============================================
# LINKS PAGE PLUGIN ===========================
RewriteRule links.html e107_plugins/links_page/links.php
RewriteRule links([0-9]*)\.html(.*)$ e107_plugins/links_page/links.php?view.$1
RewriteRule links-([0-9]*)\.html(.*)$ e107_plugins/links_page/links.php?cat.$1

# =============================================
# CONTENT PLUGIN ==============================
RewriteRule content.html e107_plugins/content/content.php
RewriteRule content([0-9]*)\.html(.*)$ e107_plugins/content/content.php?content.$1
RewriteRule content-([0-9]*)\.html(.*)$ e107_plugins/content/content.php?recent.$1

# =============================================
# STATS PLUGIN ================================
RewriteRule stats.html e107_plugins/log/stats.php
RewriteRule stats([0-9]*)\.html(.*)$ e107_plugins/log/stats.php?$1

# =============================================
# PAGE.PHP ====================================
RewriteRule page/$ page.php
RewriteRule page/([0-9]+)/$ page.php?$1

# =============================================
# FORUM PLUGIN ================================
RewriteRule forum.html e107_plugins/forum/forum.php
RewriteRule forum([0-9]*)\.html(.*)$ e107_plugins/forum/forum_viewforum.php?$1
RewriteRule forum([0-9]*)-([0-9]*)\.html(.*)$ e107_plugins/forum/forum_viewforum.php?$1.$2
RewriteRule forum-t([0-9]*)\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1
RewriteRule forum-t([0-9]*)-([0-9]*)\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1.$2
RewriteRule forum-t([0-9]*)-([0-9]*)-next\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1.$2.next
RewriteRule forum-t([0-9]*)-([0-9]*)-prev\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1.$2.prev
RewriteRule forum-t([0-9]*)-last\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1.last
RewriteRule forum-t([0-9]*)-([0-9]*)-track\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1.$2.track
RewriteRule forum-t([0-9]*)-([0-9]*)-untrack\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1.$2.untrack
RewriteRule forum-r([0-9]*)\.html(.*)$ e107_plugins/forum/forum_post.php?rp.$1
RewriteRule forum-p([0-9]*)\.html(.*)$ e107_plugins/forum/forum_post.php?nt.$1
RewriteRule forum-e([0-9]*)\.html(.*)$ e107_plugins/forum/forum_post.php?edit.$1
RewriteRule forum-t([0-9]*)-report\.html(.*)$ e107_plugins/forum/forum_viewtopic.php?$1..report
RewriteRule forum-q([0-9]*)\.html(.*)$ e107_plugins/forum/forum_post.php?quote.$1
RewriteRule top-poster-([0-9]*)-([0-9]*)\.html(.*)$ top.php?$1.top.forum.$2
RewriteRule top-active([0-9]*)\.html(.*)$ top.php?$1.active
RewriteRule top-active-([0-9]*)-([0-9]*)\.html(.*)$ top.php?$1.active.forum.$2

# =============================================
# KIG Plugin -- this does not work yet..
RewriteRule gallery.html e107_plugins/kig_menu/index.php
RewriteRule album([0-9]*)\.html(.*)$ e107_plugins/kig_menu/index.php?view=album&albumId=$1
RewriteRule image([0-9]*)\.html(.*)$ e107_plugins/kig_menu/index.php?view=image&imageId=$1

# =============================================
# GUESTBOOK PLUGIN ============================
RewriteRule guestbook\.html(.*)$ e107_plugins/guestbook/index.php

# =============================================
# PM PLUGIN ===================================
RewriteRule pm([0-9]*)\.html(.*)$ e107_plugins/pm/pm.php?send.$1

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Reply With Quote
  #2 (permalink)  
Old 19-05-2008, 10:31 PM
Junior Member
User
 
Join Date: May 2008
OS: CENTOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Lamba is on a distinguished road
Default

Is no one willing to help?
Reply With Quote
  #3 (permalink)  
Old 19-05-2008, 10:50 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 246 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

url.redirect = ( "^/show/([0-9]+)/([0-9]+)$" => "http://www.example.org/show.php?isdn=$1&page$2",
"^/get/([0-9]+)/([0-9]+)$" => "http://www.example.org/get.php?isdn=$1&page$2" )

You need to activate required modules i.e. mod_redirect and mod_rewrite in lighttpd.conf
URL redirect can be done using url.redirect directive:

Code:
url.redirect = ( 
"^/home.html$"$" => "http://domain.com/news.php",
"^/index.html$" => "http://domain.com/news.php",
"^/index.htm$" => "http://domain.com/news.php",
"^/default.html$" => "http://domain.com/news.php",
"^/default.htm$" => "http://domain.com/news.php"
)
Rewrite rules always execute before redirect rules so add them first and followed by redirect rules in following format


Code:
url.rewrite-once = ( 
 "<regex>" => "<relative-uri>",
 "<regex>" => "<relative-uri>" 
)
Here is sample
Code:
url.rewrite-once = ( 
"^/download.html$" => "download.php",
"^/downloads([0-9]*)\.html(.*)$" => "download.php?view.$1"
)
You need to test them, usually not a big difference. Following will provider
more info

Docs:ModRewrite - lighttpd - Trac
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply

Tags
htaccess , lighttpd , linux , seo


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Lighttpd rewrite Problem vBSEO Lighttpd Web servers 2 18-09-2009 08:07 PM
Lighttpd rewrite rules Melnax Web servers 0 01-06-2009 01:51 PM
Lighttpd rewrite problem Talon Web servers 4 16-10-2008 10:08 PM
Redirect + Rewrite Problem in Lighttpd Lizard King Web servers 4 17-07-2007 09:44 AM
redirect to www in lighttpd muks Web servers 11 02-06-2007 10:55 PM


All times are GMT +5.5. The time now is 06:56 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38