Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-02-23 16:07:15
- Zodiac
- Member
- Registered: 2005-04-22
- Posts: 26
URL Rewriting to Prevent Duplicate URLs
How do I edit my htaccess file to prevent duplicate URLs without breaking my site?
I have tried a few times to do some simple stuff like:
RewriteCond %{HTTP_HOST} !^fully.qualified.domain.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]
(I cannot get stupid textile to format this properly at all, sorry)
To no avail :(…
Any help would be greatly appreciated!
Last edited by Zodiac (2007-02-23 16:10:30)
Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”
Offline
Re: URL Rewriting to Prevent Duplicate URLs
I don’t understand what you want to do.
In most TXP setup, there’s no duplicate URI.
Offline
#3 2007-02-23 18:03:59
- Zodiac
- Member
- Registered: 2005-04-22
- Posts: 26
Re: URL Rewriting to Prevent Duplicate URLs
haha… yea I guess that was a pretty bad rendition of the problem at hand… but I was freaking out because I actually hosed my site… but I did get it to work, here’s what I did:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) – [PT,L] RewriteCond %{HTTP_HOST} ^nicholasbattaglia\.com RewriteRule ^(.*)$ http://www.nicholasbattaglia.com/$1 [R=301,QSA] RewriteRule ^(.*) index.phpI just wanted to force the www to be present in all URLs…
Dag?
Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”
Offline
Re: URL Rewriting to Prevent Duplicate URLs
Oh, that’s all?
Myself, I use this, but there are countless other ways to do it :
RewriteCond %{HTTP_HOST} ^www\.dorem\.info [NC]
RewriteRule ^/?(.*) http://dorem\.info/$1 [R=301,L]
(well, that’ll do the opposite, but it’s easy to reverse it).
Offline
#5 2007-02-23 18:44:32
- Zodiac
- Member
- Registered: 2005-04-22
- Posts: 26
Re: URL Rewriting to Prevent Duplicate URLs
Well mine works… so I will stay with that for now… but do you know how to eliminate image hotlinking?
Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”
Offline
#6 2007-02-23 19:10:19
- Zodiac
- Member
- Registered: 2005-04-22
- Posts: 26
Re: URL Rewriting to Prevent Duplicate URLs
And what do like, the [NC] and [R=301,L] mean??
Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”
Offline
Re: URL Rewriting to Prevent Duplicate URLs
There is no real way to stop image hotlinking. You could filter by referer, but that doesn’t work so well. But unless you have a huge bill only for this kind of things, you shouldn’t go mad about it, it’s usually not a big deal.
NC
means case insensitive
R=301
mean it’s a permanent redirect (with the appropriate http header)
L
means it’s the last rule to apply
Last edited by Jeremie (2007-02-23 20:01:30)
Offline
#8 2007-02-23 20:09:26
- Zodiac
- Member
- Registered: 2005-04-22
- Posts: 26
Re: URL Rewriting to Prevent Duplicate URLs
Well it looks like mine only worked sporadically until I put the [NC] and [R=301,L] in there… shrugs… I have no idea :-\…
Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”
Offline
Re: URL Rewriting to Prevent Duplicate URLs
For hotlinking, I was using this:
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC]
RewriteRule .*\.(jpg|gif|bmp|png)$ hotlink.jpg [L]
Blogspot and MySpace were the biggest offenders, sucking up loads of bandwidth. I created a very small jpg and placed it in my web root, it had my site url in it, hey gotta advertise :)
We Love TXP . TXP Themes . TXP Tags . TXP Planet . TXP Make
Offline