Mobile app version of vmapp.org
Login or Join
Karen161

: Apache redirect 301 /Path/aName/aName.html to /Path/aName.html not working I think my web host, 1and1, is using Apache 2.4. As per title, I have a site where I have shortened the URLs to certain

@Karen161

Posted in: #Apache #Htaccess #Redirects

I think my web host, 1and1, is using Apache 2.4.

As per title, I have a site where I have shortened the URLs to certain pages which have ended up being the sole pages in a given sub-directory, by moving them all into the parent directory, and others which I have grouped into differently named sub-directories. Redirect 301s for the former don't work, those for the latter do. My .htaccess is quite complex, so I've tried simplifying it to near the minimum required to make Redirect 301 work at all, but the problem remains, so now I'm beginning to think in terms of 'bug'.

To give more precise examples:

redirect 301 /JavaJive/PCHardware/HardwareFaults/HardwareFaults.html /JavaJive/PCHardware/HardwareFaults.html


... and all similar patterns, where the lowest source directory name, the source file name, and the destination file name are all the SAME, fail, in this case to redirect to ...

/JavaJive/PCHardware/HardwareFaults.html


... but a redirect not matching the above pattern seemingly always works, so, for example ...

redirect 301 /Shinness/ShinnessBroadband20161130.html /Shinness/FTTCPlans.html


... correctly redirects to /Shinness/FTTCPlans.html.

Can anyone suggest how to make the failing patterns work, and is this a bug?

Edit: As requested, here is the simplified .htaccess that still shows the problem ...

ErrorDocument 404 /Help.html#Error404
Options -Indexes +Includes

# Enable compresssion
# Turn this off locally, but on for live site
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilter DEFLATE .shtml
</IfModule>

# Enable includes
# (for some reason must come after compression section)
# Not needed locally, but needed for live site
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
XBitHack on

SetEnv GKEY <edited>
SetEnv UKOSKEY <edited>
RewriteEngine on
RewriteBase /

# A load of stuff here which has been shown by temporarily
# removing it to have no effect on the problem

# Redirect expired pages to nearest new equivalents
redirect 301 /CEMH.html /MacFH.html
redirect 301 /JavaJive/AudioVisualTV/SatelliteTV/SatelliteCalculator.html /JavaJive/AudioVisualTV/SatelliteTV/SatelliteCalculator.shtml
redirect 301 /JavaJive/AudioVisualTV/SatelliteTV/SatelliteCalculator.php /JavaJive/AudioVisualTV/SatelliteTV/SatelliteCalculator.shtml
redirect 301 /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.html /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.shtml
redirect 301 /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.php /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.shtml
redirect 301 /JavaJive/AudioVisualTV/ChooseTV/ChooseTV.html /JavaJive/AudioVisualTV/ChooseTV.html
redirect 301 /JavaJive/AudioVisualTV/SCART/SCART.html /JavaJive/AudioVisualTV/SCART.html
redirect 301 /JavaJive/AudioVisualTV/TVInTheUK/TVInTheUK.html /JavaJive/AudioVisualTV/TVInTheUK.html
redirect 301 /JavaJive/AudioVisualTV/TVInTheUK/TVInTheUK.rtf /JavaJive/AudioVisualTV/TVInTheUK.rtf
redirect 301 /JavaJive/PCHardware/FloppyDisks/FloppyDisks.html /JavaJive/PCHardware/FloppyDisks.html
redirect 301 /JavaJive/PCHardware/FloppyDisks/FloppySideTaped.gif /JavaJive/PCHardware/FloppySideTaped.gif
redirect 301 /JavaJive/PCHardware/FloppyDisks/FloppyTaped.gif /JavaJive/PCHardware/FloppyTaped.gif
redirect 301 /JavaJive/PCHardware/HardwareFaults/HardwareFaults.html /JavaJive/PCHardware/HardwareFaults.html
redirect 301 /JavaJive/PCHardware/PCBootProcess/PCBootProcess.html /JavaJive/PCHardware/PCBootProcess.html
redirect 301 /JavaJive/PCHardware/SCSI/SCSI.html /JavaJive/PCHardware/SCSI.html
redirect 301 /JavaJive/PCHardware/SoundBlasterLive/SBLiveConnectivity.html /JavaJive/PCHardware/SBLiveConnectivity.html
redirect 301 /JavaJive/ProgScriptWeb/GoogleGoogle.html /JavaJive/ProgScriptWeb/GoogleGoogle.shtml
redirect 301 /JavaJive/ProgScriptWeb/GoogleGoogle2.html /JavaJive/ProgScriptWeb/GoogleGoogle.shtml
redirect 301 /JavaJive/ProgScriptWeb/GoogleOpenLayers.html /JavaJive/ProgScriptWeb/GoogleOpenLayers.shtml
redirect 301 /JavaJive/ProgScriptWeb/OSLPTileMap.html /JavaJive/ProgScriptWeb/OSLPTileMap.shtml
redirect 301 /JavaJive/ProgScriptWeb/OST50TileMap.html /JavaJive/ProgScriptWeb/OST50TileMap.shtml
redirect 301 /JavaJive/ProgScriptWeb/SRTMTileMap.html /JavaJive/ProgScriptWeb/SRTMTileMap.shtml
redirect 301 /JavaJive/ProgScriptWeb/UKOSBBoxClusterStrategy.html /JavaJive/ProgScriptWeb/UKOSBBoxClusterStrategy.shtml
redirect 301 /JavaJive/ProgScriptWeb/UKOSFixedClusterStrategy.html /JavaJive/ProgScriptWeb/UKOSFixedClusterStrategy.shtml
redirect 301 /JavaJive/ProgScriptWeb/UKOSFeatures.php /JavaJive/ProgScriptWeb/UKOSFeatures.html
redirect 301 /JavaJive/ProgScriptWeb/UKOSOpenLayers.html /JavaJive/ProgScriptWeb/UKOSOpenLayers.shtml
redirect 301 /JavaJive/ProgScriptWeb/UKOSOpenLayers2.html /JavaJive/ProgScriptWeb/UKOSOpenLayers2.shtml
redirect 301 /JavaJive/ProgScriptWeb/UKOSOpenSpace.html /JavaJive/ProgScriptWeb/UKOSOpenSpace.shtml
redirect 301 /Macfarlane/Music/AtlanticRollers/AtlanticRollers.html /Macfarlane/Music/AtlanticRollers.html
redirect 301 /Macfarlane/Music/AtlanticRollers/AtlanticRollers.gif /Macfarlane/Music/AtlanticRollers.gif
redirect 301 /Macfarlane/Music/BringUsInGoodAle/BringUsInGoodAle.html /Macfarlane/Music/BringUsInGoodAle.html
redirect 301 /Macfarlane/Music/CheddarGorge/CheddarGorge.html /Macfarlane/Music/CheddarGorge.html
redirect 301 /Macfarlane/Music/DaysEnd/DaysEnd.html /Macfarlane/Music/DaysEnd.html
redirect 301 /Macfarlane/Music/MadMarchGales/MadMarchGales.html /Macfarlane/Music/MadMarchGales.html
redirect 301 /Macfarlane/Music/MartinSaidToHisMan/MartinSaidToHisMan.html /Macfarlane/Music/MartinSaidToHisMan.html
redirect 301 /Macfarlane/Music/MingulayBoatSong/MingulayBoatSong.html /Macfarlane/Music/MingulayBoatSong.html
redirect 301 /Macfarlane/Music/MingulayBoatSong/MingulayBoatSong.gif /Macfarlane/Music/MingulayBoatSong.gif
redirect 301 /Macfarlane/Music/PerfumeOnMyMind/PerfumeOnMyMind.html /Macfarlane/Music/PerfumeOnMyMind.html
redirect 301 /Macfarlane/Music/PoorOldHeap/PoorOldHeap.html /Macfarlane/Music/PoorOldHeap.html
redirect 301 /Macfarlane/Music/SallyInTheWoods/SallyInTheWoods.html /Macfarlane/Music/SallyInTheWoods.html
redirect 301 /Macfarlane/Music/SallyInTheWoods/SallyInTheWoods.gif /Macfarlane/Music/SallyInTheWoods.gif
redirect 301 /Macfarlane/Music/SallyInTheWoods/SallyInTheWoods.mid /Macfarlane/Music/SallyInTheWoods.mid
redirect 301 /Macfarlane/Music/SallyInTheWoods/SallyInTheWoods.mp3 /Macfarlane/Music/SallyInTheWoods.mp3
redirect 301 /Macfarlane/MusicTheory/Roman/Roman.html /Macfarlane/MusicTheory/Roman.html
redirect 301 /Macfarlane/Poetry/Blackout/Blackout.html /Macfarlane/Poetry/CharlesMacfarlane/Blackout.html
redirect 301 /Macfarlane/Poetry/Cavemen/Cavemen.html /Macfarlane/Poetry/CharlesMacfarlane/Cavemen.html
redirect 301 /Macfarlane/Poetry/Edwina/Edwina.html /Macfarlane/Poetry/CharlesMacfarlane/Edwina.html
redirect 301 /Macfarlane/Poetry/EyesOfSuchBlue/EyesOfSuchBlue.html /Macfarlane/Poetry/CharlesMacfarlane/EyesOfSuchBlue.html
redirect 301 /Macfarlane/Poetry/Fireside/Fireside.html /Macfarlane/Poetry/CharlesMacfarlane/Fireside.html
redirect 301 /Macfarlane/Poetry/FirstAndLast/FirstAndLast.html /Macfarlane/Poetry/CharlesMacfarlane/FirstAndLast.html
redirect 301 /Macfarlane/Poetry/Fox/Fox.html /Macfarlane/Poetry/CharlesMacfarlane/Fox.html
redirect 301 /Macfarlane/Poetry/J/J.html /Macfarlane/Poetry/CharlesMacfarlane/J.html
redirect 301 /Macfarlane/Poetry/Moonlight/Moonlight.html /Macfarlane/Poetry/CharlesMacfarlane/Moonlight.html
redirect 301 /Macfarlane/Poetry/NightRainOnBlackheath/NightRainOnBlackheath.html /Macfarlane/Poetry/CharlesMacfarlane/NightRainOnBlackheath.html
redirect 301 /Macfarlane/Poetry/Posers/Posers.html /Macfarlane/Poetry/CharlesMacfarlane/Posers.html
redirect 301 /Macfarlane/Poetry/RunawayTrain/RunawayTrain.html /Macfarlane/Poetry/CharlesMacfarlane/RunawayTrain.html
redirect 301 /Macfarlane/Poetry/Scotland/Scotland.html /Macfarlane/Poetry/CharlesMacfarlane/Scotland.html
redirect 301 /Macfarlane/Poetry/SmittenAgain/SmittenAgain.html /Macfarlane/Poetry/CharlesMacfarlane/SmittenAgain.html
redirect 301 /Macfarlane/Poetry/SunriseOverLondon/SunriseOverLondon.html /Macfarlane/Poetry/CharlesMacfarlane/SunriseOverLondon.html
redirect 301 /Macfarlane/Poetry/YearInEssex/YearInEssex.html /Macfarlane/Poetry/CharlesMacfarlane/YearInEssex.html
redirect 301 /Macfarlane/Poetry/CapeHorn/CapeHorn.html /Macfarlane/Poetry/GilesDixey/CapeHorn.html
redirect 301 /Macfarlane/Poetry/CrossingTheBar/CrossingTheBar.html /Macfarlane/Poetry/AlfredTennyson/CrossingTheBar.html
redirect 301 /Macfarlane/Poetry/Eagle/Eagle.html /Macfarlane/Poetry/AlfredTennyson/Eagle.html
redirect 301 /Macfarlane/Poetry/Ulysses/Ulysses.html /Macfarlane/Poetry/AlfredTennyson/Ulysses.html
redirect 301 /Macfarlane/Poetry/SayNotTheStruggle/SayNotTheStruggle.html /Macfarlane/Poetry/ArthurHughClough/SayNotTheStruggle.html
redirect 301 /Macfarlane/Poetry/RollingEnglishRoad/RollingEnglishRoad.html /Macfarlane/Poetry/GilbertKeithChesterton/RollingEnglishRoad.html
redirect 301 /Macfarlane/Poetry/OldShips/OldShips.html /Macfarlane/Poetry/JamesElroyFlecker/OldShips.html
redirect 301 /Macfarlane/Poetry/EpitaphForCharlesII/EpitaphForCharlesII.html /Macfarlane/Poetry/JohnWilmot/EpitaphForCharlesII.html
redirect 301 /Macfarlane/Poetry/DoverBeach/DoverBeach.html /Macfarlane/Poetry/MatthewArnold/DoverBeach.html
redirect 301 /Macfarlane/Poetry/HomeThoughtsFromAbroad/HomeThoughtsFromAbroad.html /Macfarlane/Poetry/RobertBrowning/HomeThoughtsFromAbroad.html
redirect 301 /Macfarlane/Poetry/AreYouDiggingOnMyGrave/AreYouDiggingOnMyGrave.html /Macfarlane/Poetry/ThomasHardy/AreYouDiggingOnMyGrave.html
redirect 301 /Macfarlane/Poetry/BrokenAppointment/BrokenAppointment.html /Macfarlane/Poetry/ThomasHardy/BrokenAppointment.html
redirect 301 /Macfarlane/Poetry/IFoundHerOutThere/IFoundHerOutThere.html /Macfarlane/Poetry/ThomasHardy/IFoundHerOutThere.html
redirect 301 /Macfarlane/Poetry/NeutralTones/NeutralTones.html /Macfarlane/Poetry/ThomasHardy/NeutralTones.html
redirect 301 /Macfarlane/Poetry/AnthemForDoomedYouth/AnthemForDoomedYouth.html /Macfarlane/Poetry/WilfredOwen/AnthemForDoomedYouth.html
redirect 301 /Macfarlane/Reminiscences/Accents/Accents.html /Macfarlane/Reminiscences/Accents.html
redirect 301 /Macfarlane/Reminiscences/DudLust/DudLust.html /Macfarlane/Reminiscences/DudLust.html
redirect 301 /Macfarlane/Reminiscences/HerefordshireHertfordshire/HerefordshireHertfordshire.html /Macfarlane/Reminiscences/HerefordshireHertfordshire.html
redirect 301 /Macfarlane/Reminiscences/Livermudlian/Livermudlian.html /Macfarlane/Reminiscences/Livermudlian.html
redirect 301 /Macfarlane/Reminiscences/PassAssHole/PassAssHole.html /Macfarlane/Reminiscences/PassAssHole.html
redirect 301 /Macfarlane/Reminiscences/PumpUpTheVolume/PumpUpTheVolume.html /Macfarlane/Reminiscences/PumpUpTheVolume.html
redirect 301 /Macfarlane/Reminiscences/SundayPMStroll/SundayPMStroll.html /Macfarlane/Reminiscences/SundayPMStroll.html
redirect 301 /Macfarlane/Reminiscences/VicarDogCatDuck/VicarDogCatDuck.html /Macfarlane/Reminiscences/VicarDogCatDuck.html
redirect 301 /Macfarlane/Reminiscences/WatermansArms/WatermansArms.html /Macfarlane/Reminiscences/WatermansArms.html
redirect 301 /Shinness/ShinnessBroadband20161130.html /Shinness/FTTCPlans.html
redirect 301 /PrivTest/DTM-Asc2SRTM.js /JavaJive/ProgScriptWeb/OSvsSRTM.html
redirect 301 /PrivTest/DTM-Asc2SRTM.js.txt /JavaJive/ProgScriptWeb/OSvsSRTM.html
redirect 301 /PrivTest/DTM-Asc2SRTM.py /JavaJive/ProgScriptWeb/OSvsSRTM.html
redirect 301 /PrivTest/DTM-Asc2SRTM.py.txt /JavaJive/ProgScriptWeb/OSvsSRTM.html
redirect 301 /PrivTest/DTM-Asc2SRTM.png /JavaJive/ProgScriptWeb/OSvsSRTM.html
redirect 301 /PrivTest/T502SRTM.png /JavaJive/ProgScriptWeb/OSvsSRTM.html
redirect 301 /PrivTest/JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.html /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.shtml
redirect 301 /PrivTest/JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.php /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.shtml
redirect 301 /Test/SatelliteCalculator.html /JavaJive/AudioVisualTV/SatelliteTV/SatelliteCalculator.shtml
redirect 301 /Test/SatelliteGeneral.html /JavaJive/AudioVisualTV/SatelliteTV/SatelliteGeneral.html
redirect 301 /Test/SatellitePerspective.html /JavaJive/AudioVisualTV/SatelliteTV/SatellitePerspective.html
redirect 301 /Test/SatellitePerspective1.jpg /JavaJive/AudioVisualTV/SatelliteTV/SatellitePerspective1.jpg
redirect 301 /Test/UKTerrestrialTVTest.html /JavaJive/AudioVisualTV/TerrestrialTV/TerrestrialCalculator.shtml
redirect 301 /Test/Forms.html /JavaJive/ProgScriptWeb/Forms.html
redirect 301 /Test/Google_with_Google.html /JavaJive/ProgScriptWeb/GoogleGoogle.shtml
redirect 301 /Test/Google_with_OpenLayers.html /JavaJive/ProgScriptWeb/GoogleOpenLayers.shtml
redirect 301 /Test/UKOrdnance_Survey_with_OpenLayers.html /JavaJive/ProgScriptWeb/UKOSOpenLayers.shtml
redirect 301 /Test/UKOrdnance_Survey_with_OpenSpace.html /JavaJive/ProgScriptWeb/UKOSOpenSpace.shtml
redirect 301 /Test/UKOSBBoxClusterStrategy.html /JavaJive/ProgScriptWeb/UKOSBBoxClusterStrategy.shtml
redirect 301 /Test/UKOSFixedClusterStrategy.html /JavaJive/ProgScriptWeb/UKOSFixedClusterStrategy.shtml
redirect 301 /Test/UKOSOpenSpace.html /JavaJive/ProgScriptWeb/UKOSOpenSpace.shtml
redirect 301 /Test/GoogleOLControls.html /Test/GoogleOLControls.shtml
redirect 301 /Test/GoogleOLScales.html /Test/GoogleOLScales.shtml
redirect 301 /Test/GoogleScales.png /Test/GoogleOLScales.shtml
redirect 301 /Test/GMLIEBug_Metacarta.html /Test/DeadMapDemo.html
redirect 301 /Test/GMLIEBug_UKOS.html /Test/DeadMapDemo.html
redirect 301 /Test/Google-GoogleAPI.png /Test/DeadMapDemo.html
redirect 301 /Test/Google-OpenLayers.png /Test/DeadMapDemo.html
redirect 301 /Test/GoogleInfoWindow.html /Test/DeadMapDemo.html
redirect 301 /Test/GoogleMouseTest.html /Test/DeadMapDemo.html
redirect 301 /Test/GoogleOpenLayersBugs.html /Test/DeadMapDemo.html
redirect 301 /Test/LayerBugTest.html /Test/DeadMapDemo.html
redirect 301 /Test/UKOrdnance_Survey_with_OpenLayers%20-%20Marker%20Bug.html /Test/DeadMapDemo.html
redirect 301 "/Test/UKOrdnance_Survey_with_OpenLayers - Marker Bug.html" /Test/DeadMapDemo.html

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

As mentioned in comments, when some redirects work and others don't then it suggests a conflict of some kind. The first thing to try (since it's quick) is to disable MultiViews (it's disabled by default on Apache, but it often gets enabled in many shared server environments):

Options -Indexes +Includes -MultiViews


Without knowing your filesystem structure, it's not clear whether this will have any benefit or not. But if you have directories and file basenames that share the same name then MultiViews (part of mod_negotiation) can cause problems. For instance, a request for /PCHardware/HardwareFaults could result in the file HardwareFaults.html being served, rather than the directory index inside the physical directory /HardwareFaults (if that was how your filesystem was structured).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme