-
- 16 Posts
Hi,
I am running modx revo 2.2.14-pl and am trying to setup 301 re-directs for my new site (I thought it would be a lot easier). Basically I am running revo on a Windows server enviroment, configured via IIS and running .htaccess via helicon ape. Now my .htaccess file is fine as I have setup the re-write conditions and enabled g-zip without issue, I just cant seem to figure out 301 re-directs with revo. I have searched for this issue on google and have found many threads about it, I have tried the majority and still no joy.
Please find a copy of my .htaccess file:
# Helicon Ape version 3.1.0.135
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L,QSA]
SetEnv gzip
ExpiresActive On
Header set Cache-Control public
ExpiresByType image/.+ "access 15 days"
ExpiresByType text/css "access 5 days"
ExpiresByType application/x-javascript "access 5 days"
ExpiresByType application/javascript "access 5 days"
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile .htpasswd
Require valid-user
-
- 24,544 Posts
Can you give some examples of the before and after full URLs you want?
-
- 24,544 Posts
Try this (put it at the top -- above the www and FURL rules):
RewriteEngine on
RewriteBase /
#remove .php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^(/.+)\.php$
RewriteRule ^(.+)\.php$ %1 [R=301,L]
#rewrite directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^directory-name/(.*)$ /new-directory-name/$1 [R=301,NC,L]
-
- 24,544 Posts
For this one, did you put the actual directory names in?
RewriteRule ^directory-name/(.*)$ /new-directory-name/$1
Also, try it this way:
RewriteRule directory-name/(.*)$ new-directory-name/$1
-
- 16 Posts
Hi Bob,
Yes I added the directory names to the rewrite rule and it did not work, I also tried your alternative which does not work for me either.
I have been able to setup re-directs for the old site on this server before/currently using web.config file, now I am using helicon ape / .htaccess I am having some difficulty getting it to work with the new modx site. Some of the old directories are becoming obsolete so it will be the basic request for those url's that I want to re-direct to a new url of my choice.
I have 301 redirects setup fine with several other sites including wordpress sites that I am running off the same server.
Thanks again,
Michael
-
- 24,544 Posts
I can't think of any reason why those wouldn't work, unless it's an nginx server or handles .htaccess rules in some strange way.
You could try commenting out the RewriteCond lines for those rules. Other than that, I'm afraid I don't have anything else to suggest.
-
- 24,544 Posts
I'm glad you got it sorted. Thanks for reporting back.