bibabutze
asked on
lighttpd add trailing slash.
Hi Experts,
i want to convert my mod_rewrite rules from apache to a rewrite rule for lightttpd.
All my rewrite rules work fine. But how can i check for a condition in lightttpd.
I need to put a slash at the end of each url.
In Apache i use:
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
now when i try:
url.rewrite-once = ("^(.*)$" => "http://%{HTTP_HOST}/$1/")
it doesnt work. is there a way in lighttpd to put a slash at the ent of url if not exist?
i want to convert my mod_rewrite rules from apache to a rewrite rule for lightttpd.
All my rewrite rules work fine. But how can i check for a condition in lightttpd.
I need to put a slash at the end of each url.
In Apache i use:
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
now when i try:
url.rewrite-once = ("^(.*)$" => "http://%{HTTP_HOST}/$1/")
it doesnt work. is there a way in lighttpd to put a slash at the ent of url if not exist?
ASKER
i think of something like redirect. So if there is no slash at the end the page is redirect to the page with the slash at the end.
i tried this
$HTTP["host"] =~ "/[^\.]+[^/]" {
url.redirect = ( "^/(.*)" => "http://%1/$1/" )
}
but it doesn´t work
i tried this
$HTTP["host"] =~ "/[^\.]+[^/]" {
url.redirect = ( "^/(.*)" => "http://%1/$1/" )
}
but it doesn´t work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i still have one problem with your rule.
www.mypage.com/mytest
www.mypage.com/mytest/
both links are working, But the last slash is not displayed in the url.
This will lead to duplicate content for google and other searchengines.
So is there a simple way with lighttpd like in apache to display always a slash at the end.
www.mypage.com/mytest
www.mypage.com/mytest/
both links are working, But the last slash is not displayed in the url.
This will lead to duplicate content for google and other searchengines.
So is there a simple way with lighttpd like in apache to display always a slash at the end.
ASKER
does anybody else have an idea how to solve this
Open in new window