PDA

View Full Version : htaccess for several things


TacticalNuke
07-25-2008, 06:29 PM
Alright so currently I have my .htaccess file set up for vbseo sitemap, I have it set as unreadable, and I have it redirect the old Zoints tags system to the new built-in tags system.

However, I have two problems. One, I want to redirect site.com to www.site.com.

The other problem is that .com is PR 2 and .com/index.php is PR 1. I'm assuming I should set a redirect from index.php to the plain .com but I'm not sure how to do that.

I saw this code for the www issue in another thread: RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

And here is my current .htaccess:

RewriteEngine On
RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

<Files .htaccess>
order allow,deny
deny from all
</Files>

Redirect /tags/ http://www.serviceacademyforums.com/tags.php


Can anybody help me add the redirect to www and help me decide if I should direct to index.php or plain .com and how to do that?

Thanks, I'd really appreciate it.

--------------- Added 1217030827 at 1217030827 ---------------

I'm sorry, this probably should have gone in the programming section, could a mod please move it? Thanks.

Dismounted
07-26-2008, 05:27 AM
RewriteEngine On

RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

<Files .htaccess>
order allow,deny
deny from all
</Files>

Redirect /tags/ http://www.serviceacademyforums.com/tags.php

TacticalNuke
07-26-2008, 10:49 AM
Thanks a lot for the help. One last question, how (and should I) would I redirect .com/index.php to .com?

For some reason PR on just the .com is 2, while /index.php is 1. I'm not sure if this is a big deal or not, so maybe I don't need to do it at all.

Dismounted
07-26-2008, 10:49 AM
Don't worry about it IMO.

TacticalNuke
07-26-2008, 10:52 AM
Don't worry about it IMO.

Sounds good, thanks again for all the help and the quick responses.

TacticalNuke
07-27-2008, 06:04 PM
So I tried using that redirect, replacing example with my website name, but I got an error in firefox that the redirect will "never complete".

I'm wondering if I didn't put in the information correctly, or if there's something wrong with the coding that I took from somewhere else.

Dismounted
07-28-2008, 06:19 AM
RewriteEngine On

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

RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

<Files .htaccess>
order allow,deny
deny from all
</Files>

Redirect /tags/ http://www.serviceacademyforums.com/tags.php

TacticalNuke
07-28-2008, 10:45 AM
Thank you again.

I have one final question (I know, lots of questions).

I thought I had my old tags redirecting properly, but google webmaster tools has a bunch of not found urls, 509 to be exact.

They all look like this:

http://www.serviceacademyforums.com/tags/index.php/1st-time-through/
http://www.serviceacademyforums.com/tags/index.php/2-nominations/
http://www.serviceacademyforums.com/tags/index.php/2008-graduation/

etc....

Once those links are clicked, they "change":

http://www.serviceacademyforums.com/tags.phpindex.php/2008-graduation/

like so. So /tags/ isn't redirecting them. I tried a /tags. but that didn't work.

It almost seems like the /tags/ redirect is redirecting them but there's a problem. Instead of just redirecting them to the main tags area, it's appending whatever comes after the /tags/ to the redirect location (in this case /tags.php) so I end up with /tags.index.php/*******

I'm guessing my redirect is improperly formed, I hope this makes sense. I've tried a number of permutations but basically I just want any /tags to redirect to http://www.serviceacademyforums.com/tags.php without appending whatever else was on the link to the end of it.

As always, I really appreciate it, I don't know what I'd do without this forum.

Dismounted
07-28-2008, 11:52 AM
Can you give me a "before and after" of the link (of what it is supposed to look like).

TacticalNuke
07-28-2008, 05:29 PM
Not found URL:

[not url]http://www.serviceacademyforums.com/tags/index.php/1st-time-through/[/url]

These are all (I'm assuming) leftovers of the Zoints tag system. I used one of the mods here to import them all to the vB tags system, but google still has some of the links.

I wanted to redirect to:

[not url]http://www.serviceacademyforums.com/tags.php/[/url]

As I think this makes the most sense, if someone is searching for tags to begin with this seems like a good place to send them.

My current .htaccess redirect is:

#redirecting old zoints tags to vb tags
Redirect /tags http://www.serviceacademyforums.com/tags.php/

The trouble is this makes the links look as such:

[not url]http://www.serviceacademyforums.com/tags.php//index.php/1st-time-through/[/url]

So it's appending what comes after (/index.php/1st-time-through/) to the redirect location.

I've tried several wildcard redirects that I found through google searching, but all of them give me errors and don't work. I don't understand redirects very well though.

As always, I appreciate the help. :)

Dismounted
07-29-2008, 06:48 AM
RewriteEngine On

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

RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteRule ^tags/ http://www.serviceacademyforums.com/tags.php

<Files .htaccess>
order allow,deny
deny from all
</Files>

TacticalNuke
07-30-2008, 09:15 PM
I gave this a try but am still having the problem where it takes the inbound link, then appends the end of it to the redirect link.

So instead of just redirecting to one location, it adds part of the redirected link to the destination.

Basically the easiest way I think would be to take the inbound links and put them to all my tags. The "better" option I guess would be to append the inbound link's "tag" to the vb tag system link, but that may be more complicated than it's worth.

Thank you as always for your incredible help, Dismounted, I'm sorry to keep posting about this, but I've tried a lot of different methods and can't seem to get it to work out.

Dismounted
07-31-2008, 06:55 AM
RewriteEngine On

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

RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteRule ^tags/ http://www.serviceacademyforums.com/tags.php [R=301,L]

<Files .htaccess>
order allow,deny
deny from all
</Files>

TacticalNuke
08-01-2008, 04:29 AM
That did the trick, thanks. :up::up: