IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Can someone check my mod_rewrite rule?
I'm moving my blog, and taking the opportunity to move it from a subdomain to a directory. Current URL structure is:

http://blog.domain.com/year/month/title.html

New structure is:

http://domain.com/blog/year/month/title/

What I've got in .htaccess is:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^blog\.cooklikeyourgrandmother\.com
RewriteRule ^http://blog\.(.*)\.html$ http://cooklikeyourgrandmother\.com/blog/$1/ [R=301,L]


Does that look right? And second, if there is already another rewrite block, do I need to repeat the "RewriteEngine On" directive? In other words, should it be:

RewriteEngine On

condition
condition
rule 1

condition
rule 2


or

RewriteEngine On

condition
condition
rule 1

RewriteEngine On
condition
rule 2
--

Drew
New Re: Can someone check my mod_rewrite rule?
One declaration per vhost for "RewriteEngine On"


RewriteCond %{HTTP_HOST} ^blog\.cooklikeyourgrandmother\.com

RewriteRule ^http://blog\.(.*)\.html$ http://cooklikeyourgrandmother\.com/blog/$1/ [R=301,L]


That to me looks like you are not understanding it properly (or typo'd).

That particular rewrite rule expands to this:

http://cooklikeyourgrandmother.com/blog/cooklikeyourgrandmother.com/year/month/title/

Unless less you meant:
RewriteRule ^http://blog\.cooklikeyourgrandmother\.com/(.*)\.html$ http://cooklikeyourgrandmother\.com/blog/$1/ [R=301,L]



You might also want to take the time to prevent image theft. Using something similar to:

SetEnvIfNoCase Referer !\.cooklikeyourgrandmother\.com no-external-linking=1

ReWriteCond %{ENV:no-external-linking} 1
RwriteRule \.(gif|GIF|jpg|JPG|png|PNG)$ /bollocks/no-external-linking.png [PT,MC]


New Yeah, was a typo -- solved
But this:
RewriteRule ^http://blog\.cooklikeyourgrandmother\.com/$ http://cooklikeyourgrandmother\.com/blog/ [R=301,L]

keeps giving me
Forbidden

You don't have permission to access / on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


If I redirect everything:
RewriteRule .* http://cooklikeyourgrandmother\.com/blog/ [R=301,L]

it works, so something in the match pattern isn't matching.


[edit]

In an .htaccess file, RewriteRule starts looking after the domain. The rule I wrote would have worked in an httpd.conf file.
--

Drew
Expand Edited by drook Nov. 25, 2009, 12:50:26 PM EST
     Can someone check my mod_rewrite rule? - (drook) - (2)
         Re: Can someone check my mod_rewrite rule? - (folkert) - (1)
             Yeah, was a typo -- solved - (drook)

Tasty little nuggets of alien technology...
34 ms