Hi everybody, If anyone is an expert in url rewriting, I'd really appreciate your help with this one.
Here's the background info - I'm redirecting an exact replica of the site, 'old-domain.tld' to the site, 'new-domain.tld/newdirectory'
Using the following htaccess code in my OLD site's root,
Redirect 301 / http://www.new-domain.tld/
I have successfully managed to direct my files to the same filename in the root of the NEW site (obviously the files don't exist here, because they're in the subdirectory entitled 'newdirectory'...)
So using the following htaccess code in the root of the NEW site,
RewriteEngine on
RewriteBase /
RewriteRule ^$ newdirectory/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ newdirectory/$1 [L]
I have manged to hide the subdirectory, 'newdirectory' from MOST of my urls (which are also htaccess coded to force users to www version and display search engine friendly .html endings without index.php).
To get this to work, I also had to leave the base url or 'Relative Path to Contao Directory' in Contao's settings blank - so that all auto-generated relative links would NOT include the subdirectory, 'newdirectory'.
So now, http://www.old-domain.tld/events.html successfully redirects you to http://www.new-domain.tld/events.html (with 'newdirectory' hidden from the url).
The big BUT however, is that when I try to access the admin url for Contao or Typolight, it puts the 'newdirectory' back into the url - UNLESS I type a trailing slash.
So, 'http://www.old-domain.tld/contao' takes me to 'http://www.new-domain.tld/newdirectory/contao'
Whereas, 'http://www.old-domain.tld/contao/' takes me to 'http://www.new-domain.tld/contao' (where I want to be).
Only problem is that users won't remember to type in the trailing slash.
Once in the backend, depending on where you are, the 'newdirectory' is sometimes present, and sometimes not - plus it causes the user to be taken to random places within the backend when they press something like 'save and close' or 'go back'.
I have noted the main difference here is that I am trying to rewrite a folder ('http://www.old-domain.tld/contao') instead of a filename ('http://www.old-domain.tld/events.html') or perhaps it's conflicting with some other redirect within Contao - but not sure how to remedy it.
Please HELP!! :-)
Bookmarks