The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
.htaccess riddle - guru needed!
I have some working .htaccess code (below). I would love to make this a [R=301] permanent redirect so PageRank is passed from our old links. When I simply add [R=301] to the last statement, it adds .php to hte urls.
.htaccess below: /headlines/ .htacess with R=301: /headlines.php/ Any ideas on how to do this properly? I'm not sure why the redirect changes the working rewrite. Code:
RewriteEngine On RewriteBase /news/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^/]+)/?(.*) $1.php/$2 [L] |
#2
|
|||
|
|||
here's a Link on how to do a Redirect:
http://www.vbulletin.com/forum/showthread.php?t=247241 and also to redirect from 1 forum to another: http://www.vbulletin.com/forum/showthread.php?t=247216 hth (And Mod's if linking to vb.com isn't allowed, would someone give me a holler and let me know! Thnx) |
#3
|
||||
|
||||
It's adding the .php because you have .php in your rewrite rule. No mystery about it.
Give me an example URL that you want to permanently redirect to another URL and I'll give you the rewrite rule. |
#4
|
|||
|
|||
Sockwater, I did a poor job explaining the problem. I'm not as slow as I look, I promise. I'm working with someone else's code and trying to understand exactly what's going wrong.
I have a file called headlines.php. With the .htaccess posted above, you can access it via: http://www.diabetesdaily.com/news/headlines.php OR http://www.diabetesdaily.com/news/headlines/. Or you could access: http://www.diabetesdaily.com/news/headlines/page/1 OR http://www.diabetesdaily.com/news/headlines.php/page/1 If I make this a 301 redirect it goes to 404. If I remove the .php from the .htaccess file, I get a server error. If I add a 301 redirect and remove the .php, it goes to 404. Ideally, I think I want to make the last line a 301 redirect AND redirect from headlines.php to headlines. Is this more clear? I feel like I can follow the current .htaccess, but I'm at a total loss how to describe what I want to happen. |
#5
|
||||
|
||||
I wasn't trying to imply you were slow..
I would do something like this, but it's kind of hard to tell, not knowing how your scripts work. Code:
# permanently redirect headlines.php to headlines/ (change the url) RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^news/headlines.php$ headlines/ [L,R=301] # send the headlines/ url to the headlines.php script behind the scenes (don't change url) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^headlines/(.*)$ headlines.php?uri=$1 [L] |
#6
|
|||
|
|||
That works perfectly for my specific example. Using my own brain power, I'm going to make a generic edition of that rewrite. Thanks for the assistance!
|
#7
|
||||
|
||||
To make it more generic, while still controlling the input, you could try something like this:
Code:
RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^news/(headlines|otherscript|yetanother).php$ $1/ [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(headlines|otherscript|yetanother)/(.*)$ $1.php?uri=$2 [L] |
#8
|
|||
|
|||
I got it working. We've been bouncing between the 5 and 7 spots on Google for "diabetes news" but have thousands of incoming links pointing at three different URLS. By consolidating them into one, we hope to jump towards number one. Thanks very much for your help as always.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|