Solved

.htacess redirect not working

Posted on 2011-09-16
5
256 Views
Last Modified: 2012-05-12
Hi,

I've just changed the name of one of my php pages and I'm wanting to redirect requests made to the former filename to go to the new filename.

The old page is:
news/event.php?event=

The new page is:
news/predictions.php?event=

I tried using this in .htaccess:

RewriteRule ^news/predictions.php?event=([0-9]{2}) news/predictions.php?event=$1 [r=301,nc]

I tried accessing the orginal url but it didnt redirect me to the new one. Can anyone see where i'm going wrong?

Thanks,

Paul

Am I using this wrong? I tried
0
Comment
Question by:m0tSiE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Derokorian
ID: 36550176
First you are redirecting from prediction to predictions. This is a problem. Secondly, you never close your pattern using the $ symbol. Finaly, I think you can use:

RewriteRule ^news/event.php$ news/predictions.php [QSA,R=301,NC]

HTH
0
 

Author Comment

by:m0tSiE
ID: 36550223
Thanks Derokorian, I tried your code and it does redirect but it uses the full server path including public_html, etc. is there a way to stop it adding in those extra folders? or should I just change news/predictions.php to the full url?
0
 
LVL 11

Assisted Solution

by:Amar Bardoliwala
Amar Bardoliwala earned 50 total points
ID: 36550266
Hello m0tSiE,

You can try any of following

1. add full url like http://yoursite.com/news/predictions.php

or

2. try /news/predictions.php

Hope this helps.

Thank You.

0
 
LVL 10

Accepted Solution

by:
Derokorian earned 450 total points
ID: 36550317
Personally I use:


RewriteEngine ON
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule (.+) $1 [L]

#other rewriterules here such as yours:
RewriteRule ^news/event.php$ news/predictions.php [QSA,R=301,NC]

Open in new window



or you can use the leading slash as amar suggested
0
 

Author Closing Comment

by:m0tSiE
ID: 36550331
Thanks guys, worked perfectly.

:)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question