Forum Moderators: phranque
RewriteEngine On
Options +FollowSymlinks
RewriteBase /test/### ausgeschlossene Ordner
RewriteRule ^css/ - [L]
RewriteRule ^img/ - [L]
### 301 Weiterleitung auf WWW
RewriteCond %{HTTP_HOST} !^www.example\.com$
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]
###RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
###RewriteRule [^/]$ %{REQUEST_URI}/ [R=301]
###RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]
# ohne Schrägstrich am Ende
RewriteRule (.+)/$ /test/$1 [L,R=301]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/item/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3&item=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3&fab=$4 [L]
my old linkstructure was in this way... www.example.com/index.php?lang=de&i=about
the new structure is in this way.. www.example.com/test/de/about
the "test" in the link is the current place for testing...
to this way everything folds. but i want my old links which are indexed by google redirect to the new url! because of DC and PR.
now i reach my site still over the old link structure like this example
www.example.com/test/index.php?lang=de&i=about
which i dont want! the old link should be directed to
www.example.com/test/de/about via 301
I would be pleased if me someone to help could please!
sorry for my bad english! hope you understand what i mean!
best regards
bernte
[edited by: jdMorgan at 11:22 pm (utc) on July 27, 2008]
[edit reason] example.com [/edit]
After all of the redirects are listed, you should have your rewrites, again, from most specific through to most general.
RewriteEngine On
Options +FollowSymlinks
RewriteBase /test/### barred folders
RewriteRule ^css/ - [L]
RewriteRule ^img/ - [L]
### 301 redirect to WWW
RewriteCond %{HTTP_HOST} !^www.example\.com$
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]
# no slash at last
RewriteRule (.+)/$ /test/$1 [L,R=301]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/item/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3&item=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3&fab=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2 [L]
is it that what you mean?
i think my links are all canonical
and what do you mean with "The catch-all for all non-www should be the very last."
do you mean that i have to put this
### 301 redirect to WWW
RewriteCond %{HTTP_HOST} !^www.example\.com$
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]
and what is with my other problem?
now i reach my site still over the old link structure like this example
www.example.com/test/index.php?lang=de&i=aboutwhich i dont want! the old link should be directed to
www.example.com/test/de/about via 301
regards berni
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/item/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3&item=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3&fab=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2&cat=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&i=$2 [L]
RewriteRule ^([^/]+)$ index.php?lang=$1 [L]
has anybody also an idea to this problem?
thanks for your help!
best regards berni
To get started on finding the answer to your original question, see this recent thread [webmasterworld.com].
Jim
This rule does not enforce the www and as it is more specific it should be before your non-www to www redirect.
It needs to also enforce www within the rule, rather than chaining with some other rule.
.
You also have a rewrite at the very start of the code, but you should place all your rewrites after all of the redirects.
i dont know how i can explain because my english is not very good but i will try!
look at this code
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=$3&item=$4 [L]
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=$3&fab=$4 [L]
the problem is that just works the first rule!
i think the problem is that the first and second rule has the same code just the end with item and fab is the difference.
the fab in the 2nd rule is just needed for on area
like this.. &cat=$3 is always cat=manufaturer&fab=$4
can somebody tell me how it works?
best regards
bernte
When I needed to do something like this before, I was lucky that for one parameter, the value could be either four digits or seven digits. That made it easy to select out which rule needed to be used.
RewriteRule ^test/([^/]+)/([^/]+)/manufacturer/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=manufacturer&item=$3 [L]
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=$3&item=$4 [L]
Jim
now on weekend i wanted to get online with the modrewrited site from my uncle.. but i got an new error! and i have no idea why.
the problem are the subdirs in my testfolder
before i had the problem some post on top i got access to the test/css/ and test/img/ folder
now i saw that it doesnt work anymore!
when i go to http://www.example.com/test/css the page moves to http://www.example.com/test/css?lang=css and i become an error in firefox!
i try to translate the error:
Error: forwardingerror
The inquiry reroutes the called website in such a way that it can be never terminated.
could somebody take a look again at my code please?
RewriteEngine On
Options +FollowSymlinks### 301 redirect to WWW
#RewriteCond %{HTTP_HOST} !^www.example\.com$
#RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]
# no slash at last
RewriteRule ^test/([^/]+(/[^/]+)*)/$ /test/$1 [L,R=301]
### freigegebene ordner
RewriteRule ^test/css/ - [L]
RewriteRule ^test/img/ - [L]
### tatsaechliche files ausschliessen
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^test/index\.php$ - [L]
RewriteRule ^test/([^/]+)/([^/]+)/fabricant/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=fabricant&fab=$3 [L]
RewriteRule ^test/([^/]+)/([^/]+)/fabricante/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=fabricante&fab=$3 [L]
RewriteRule ^test/([^/]+)/([^/]+)/hersteller/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=hersteller&fab=$3 [L]
RewriteRule ^test/([^/]+)/([^/]+)/manufacturer/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=manufacturer&fab=$3 [L]
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=$3&item=$4 [L]
## shippingform - vorn und hinten aendern
RewriteRule ^test/([^/]+)/estimation_envoi/([^/]+)$ /test/index.php?lang=$1&i=estimation_envoi&item=$2 [L]
RewriteRule ^test/([^/]+)/gastos_envio/([^/]+)$ /test/index.php?lang=$1&i=gastos_envio&item=$2 [L]
RewriteRule ^test/([^/]+)/versandanfrage/([^/]+)$ /test/index.php?lang=$1&i=versandanfrage&item=$2 [L]
RewriteRule ^test/([^/]+)/shipping_request/([^/]+)$ /test/index.php?lang=$1&i=shipping_request&item=$2 [L]
## orderform - vorn und hinten aendern
RewriteRule ^test/([^/]+)/commande/([^/]+)$ /test/index.php?lang=$1&i=commande&item=$2 [L]
RewriteRule ^test/([^/]+)/orden_form/([^/]+)$ /test/index.php?lang=$1&i=orden_form&item=$2 [L]
RewriteRule ^test/([^/]+)/bestellformular/([^/]+)$ /test/index.php?lang=$1&i=bestellformular&item=$2 [L]
RewriteRule ^test/([^/]+)/orderform/([^/]+)$ /test/index.php?lang=$1&i=orderform&item=$2 [L]
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+)$ /test/index.php?lang=$1&i=$2&cat=$3 [L]
RewriteRule ^test/([^/]+)/([^/]+)$ /test/index.php?lang=$1&i=$2 [L]
RewriteRule ^test/([^/]+)$ /test/index.php?lang=$1 [L]
ErrorDocument 403 /test/error/403.php
ErrorDocument 404 /test/error/404.php
best regards berni
the website with the rules works fine.. just when i want manually go to an existing subfolder which really exists comes the error..
when u understand me right and i must create a rewritecond i dont know how :(
i did it with the code in line 11
### freigegebene ordner
RewriteRule ^test/css/ - [L]
RewriteRule ^test/img/ - [L]
can you tell me what i have to do to get access to these folders?
### freigegebene ordner
RewriteRule ^test/css/ - [L]
RewriteRule ^test/css - [L]
RewriteRule ^test/img/ - [L]
RewriteRule ^test/img - [L]
when i now try to reach
http://www.example.com/test/css the site dont moves to http://www.example.com/test/css?lang=css
it stays right at
http://www.example.com/test/css
the same with
http://www.example.com/test/css/ the site dont moves to http://www.example.com/test/css/?lang=css
it stays right at
http://www.example.com/test/css/
but the error-message in firefox is still the same :(
Error: forwardingerror
The inquiry reroutes the called website in such a way that it can be never terminated.
i check this folder with [web-sniffer.net...]
when i check
http://www.example.com/test/img comes
HTTP Status Code: HTTP/1.1 301 Moved Permanently to
http://www.example.com/test/img/
when i check it on the other way
http://www.example.com/test/img/ comes
HTTP Status Code: HTTP/1.1 301 Moved Permanently to
http://www.example.com/test/img
i think thats it why comes the error in firefox.. its an never ending loop
is it my rule that makes the error on line 8
# no slash at last
RewriteRule ^test/([^/]+(/[^/]+)*)/$ /test/$1 [L,R=301]
i create this rule that i become no dublicate content!
and for all the sites it works...
example:
when i go to http://www.example.com/test/en/about/
site moved to http://www.example.com/test/wn/about
but i dont want it for the real folders
# no slash at last
RewriteRule ^test/(.+)/$ [b]http://www.example.com[/b]/test/$1 [R=301,L]
#
# 301 redirect to WWW
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
but it changed noting.. i got the same result with web-sniffer.
[edited by: jdMorgan at 5:01 pm (utc) on Aug. 24, 2008]
[edit reason] No URLs, please. [/edit]
That looks like a problem in two ways. First, it looks like /test/index.php and /test/css might be "not OK" and could be redirected.
Second, this error-handling method is very bad for search engines; The method should be, "If not OK, then issue 404-Not Found server response, and generate 404 error page." The 404 error page should then contain text links to your home page, site map, site search page, etc. You should never redirect (301, 302, 303, or 307) errors to your home page, because this can create massive duplicate-content propblems -- You should always send the proper error response and output a "helpful" page for the user.
Jim
### freigegebene ordner
RewriteRule ^test/css/? - [L]
RewriteRule ^test/img/? - [L]
Jim
here is my code
ErrorDocument 403 /test/error/403.php
ErrorDocument 404 /test/error/404.php
RewriteEngine On
Options +FollowSymlinks
### freigegebene ordner
RewriteRule ^test/css/? - [L]
RewriteRule ^test/img/? - [L]
now i have another question :D
is that the only way to get access to the folders?
for example:
the site is only and i create ne new folder in the root pub or something other... must i now write every folder in the htaccess?
because when i go now to test/css/ or test/img/ i become an 403 <-- thats right beause there is no file inside!
but when i go for example to test/#*$!/ which folder realy exists but is not write down in the htaccess i become again the forwarding error.
or is there another error?
i want to say 1000 thanks to all the helpers
berni