Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with .htaccess

Posted on 2011-03-02
14
Medium Priority
?
370 Views
Last Modified: 2012-05-11
Hello Experts
I'm a bit stuck with my .htaccess syntax on one of my websites.

Basically I want to redirect 301 any request for index.php to www.allstretchedout.co.uk. I already have several 301 redirects on the file and rewrite non www to www etc but if I add
 
Redirect 301 /index.php http://www.allstretchedout.co.uk/

Open in new window

to the file it causes the Apache test page to show. I've reproduced the .htaccess file below:
 
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^allstretchedout.co.uk [nc]
rewriterule ^(.*)$ http://www.allstretchedout.co.uk/$1 [r=301,nc]



Redirect 301 /booking.php http://www.allstretchedout.co.uk/bookings.php
Redirect 301 /aboutus.html http://www.allstretchedout.co.uk/about-us.php
Redirect 301 /aboutusrentals.html http://www.allstretchedout.co.uk/about-us.php
Redirect 301 /phantom.html http://www.allstretchedout.co.uk/rolls-royce-phantom.php
Redirect 301 /mardigras.html http://www.allstretchedout.co.uk/mardi-gras.php
Redirect 301 /hellfire.html http://www.allstretchedout.co.uk/hellfire.php
Redirect 301 /hellraiser.html http://www.allstretchedout.co.uk/hellfire.php
Redirect 301 /rangerover.html http://www.allstretchedout.co.uk/view-cars.php
Redirect 301 /pinkminx.html http://www.allstretchedout.co.uk/pink-minx.php
Redirect 301 /rentals.html http://www.allstretchedout.co.uk/view-cars.php
Redirect 301 /bentley.html http://www.allstretchedout.co.uk/bentley-arnage-t.php
Redirect 301 /stargazer.html http://www.allstretchedout.co.uk/stargazer.php
Redirect 301 /inferno.html http://www.allstretchedout.co.uk/inferno.php
Redirect 301 /attitude.html http://www.allstretchedout.co.uk/attitude.php
Redirect 301 /mercedes.html http://www.allstretchedout.co.uk/view-cars.php
Redirect 301 /pink_panther.htm http://www.allstretchedout.co.uk/pink-panther.php
Redirect 301 /pinkminxvideo.html http://www.allstretchedout.co.uk/pink-minx.php
Redirect 301 /contact.html http://www.allstretchedout.co.uk/contact-us.php
Redirect 301 /stargazervideo.html http://www.allstretchedout.co.uk/stargazer.php
Redirect 301 /attitudevideo.html http://www.allstretchedout.co.uk/atttitude.php
Redirect 301 /hellraiservideo.html http://www.allstretchedout.co.uk/hellfire.php
Redirect 301 /mardigrasvideo.html http://www.allstretchedout.co.uk/mardi-gras.php
Redirect 301 /bentley-arnage.html http://www.allstretchedout.co.uk/bentley-arnage-t.php
Redirect 301 /tuxedo-royale.html http://www.allstretchedout.co.uk/bookings.php
Redirect 301 /booking.php http://www.allstretchedout.co.uk/view-cars.php
Redirect 301 /platinum-plaza.html http://www.allstretchedout.co.uk/platinum-plaza.php


AddType text/x-component .htc


php_flag magic_quotes_gpc off

Open in new window

Any help would be most appreciated.

Thanks in advance.
0
Comment
Question by:Mick_Eden
[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
  • 7
  • 7
14 Comments
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35019342
You get the Apache "Test Page", are you meaning the default index.html that comes with an Apache Install?

Do you have your DirectoryIndex configured to use index.php?  I.E.

DirectoryIndex index.php
0
 

Author Comment

by:Mick_Eden
ID: 35019498
this is the page I see:

 screenshot
I'm not sure about the rest of your question regarding DirectoryIndex - it is on a shared hosting package  if that has any bearing?

0
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35019554
Ok, well add

DirectoryIndex index.php

to your .htaccess, and see if that solves your issue.
0
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 

Author Comment

by:Mick_Eden
ID: 35019634
No, that made no difference, it still went to the Apache page
0
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35019749
Instead of doing a redirect 302, try an internal RewriteRule.

I'm assuming that for some reason, the "host:" header is being ripped out of the request, so you getting sent to another site being hosted on the systems yours is hosted on.

try:

 RewriteRule ^/index.php$ http://www.allstretchedout.co.uk/ [NC]

effectively the same thing, but perhaps it will better preserve the host header information.
0
 

Author Comment

by:Mick_Eden
ID: 35019827
I've tried this, but while it doesn't cause the Apache issue, it doesn't actually strip the index.php from the url. If you go to the site the home page shows without the index.php ext, but if I click on any link to take me back to the homepage it does show index.php in the url, which for search engine reasons I want to avoid
0
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35019881
maybe need a permanent redirect?

RewriteRule ^/index.php$ http://www.allstretchedout.co.uk/ [NC,R=302]
0
 

Author Comment

by:Mick_Eden
ID: 35020451
Afraid it's no different with a 302
0
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35020549
Just throwing out suggestions... I see a redirect loop happening at some point...

RewriteRule ^/index.php$ http://www.allstretchedout.co.uk/ [L,R=301]
0
 

Author Comment

by:Mick_Eden
ID: 35020656
Nope, still no effect
0
 
LVL 9

Accepted Solution

by:
jeremycrussell earned 2000 total points
ID: 35020760
RewriteRule ^/index.php$ / [QSA]
0
 

Author Comment

by:Mick_Eden
ID: 35020863
Nope, still no effect.

I think I'll just accept that it's not going to work - it's not that big a deal really.

Thanks for your help and I'll give you the points anyway.
0
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35020894
One thing you might try to do is configure links on the other pages to point back the / instead of /index.php.

I apologize for not being able to find you a solution.
0
 

Author Comment

by:Mick_Eden
ID: 35021035
No problem, I tried changing the link to just the / but it still goes to index.php. I did try putting an absolute url http://www.allstretchedout.co.uk as the link and this does work but I am concerned that search engines will not like that method.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
There have been a lot of times when we have seen the need to enter a large number of DNS entries in a forward lookup zone. The standard procedure would be to launch the DNS Manager console, create the Zone and start adding new hosts using the New…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 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