Frank Vèssia Posted February 5, 2011 Share Posted February 5, 2011 I recreated a site using PW and i need to redirect some old urls to new but the rediret directive in .htaccess file is not working good, PW send me to 404 page and the url became www.mysite.com/new-page/?it=old-page.html Link to comment Share on other sites More sharing options...
Adam Kiss Posted February 5, 2011 Share Posted February 5, 2011 You need to post your .htaccess here, it sounds, like you have something wrong there. (Some could probably tell you what it is at this point, but I would rather see your .htaccess before I give you any tip) Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 5, 2011 Author Share Posted February 5, 2011 Done. ################################################################################################# # START PROCESSWIRE HTACCESS DIRECTIVES ################################################################################################# Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteCond %{http_host} ^soddisfa [NC] RewriteRule ^(.*)$ http://www.soddisfa.com/$1 [R=301,L] Redirect /6-amicizie.html http://www.soddisfa.com/amicizie/ # ----------------------------------------------------------------------------------------------- # Access Restrictions: Keep web users out of ProcessWire system files # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_URI} (^|/)\.htaccess$ [NC,OR] RewriteCond %{REQUEST_URI} (^|/)site/assets/(cache|logs|backups|sessions|config|install)($|/.*$) [OR] RewriteCond %{REQUEST_URI} (^|/)site/install($|/.*$) [OR] RewriteCond %{REQUEST_URI} (^|/)(wire|site)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ [OR] RewriteCond %{REQUEST_URI} (^|/)site/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR] RewriteCond %{REQUEST_URI} (^|/)site/assets($|/|/.*\.php)$ [OR] RewriteCond %{REQUEST_URI} (^|/)wire/(core|modules)/.*\.(php|inc|tpl|module)$ [OR] RewriteCond %{REQUEST_URI} (^|/)site/modules/.*\.(php|inc|tpl|module)$ [OR] RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|htaccess)\.txt$ RewriteCond %{REQUEST_URI} (^|/)site-default/ RewriteRule ^.*$ - [F,L] # ----------------------------------------------------------------------------------------------- # Ensure that the URL follows the name-format specification required by ProcessWire # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_URI} "^[-_.a-zA-Z0-9/]*$" # ----------------------------------------------------------------------------------------------- # If the request is for a file or directory that physically exists on the server, # then don't give control to ProcessWire, and instead load the file # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # ----------------------------------------------------------------------------------------------- # Pass control to ProcessWire if all the above directives allow us to this point. # ----------------------------------------------------------------------------------------------- RewriteRule ^(.*)$ index.php?it=$1 [L,QSA] ################################################################################################# # END PROCESSWIRE HTACCESS DIRECTIVES ################################################################################################# I'm not expert of htaccess code maybe some PW code here fails the redirect... Link to comment Share on other sites More sharing options...
Adam Kiss Posted February 5, 2011 Share Posted February 5, 2011 Hm, I would try to move the # I also added 301 HTTP status Redirect 301 /6-amicizie.html http://www.soddisfa.com/amicizie/ Before the non-www -> www part Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 5, 2011 Author Share Posted February 5, 2011 it's the same , the www part tell only using always the www domain to avoid duplicated contents but other behavior remain the same Link to comment Share on other sites More sharing options...
Adam Kiss Posted February 5, 2011 Share Posted February 5, 2011 1: Try to add [L] after the redirect. 2: Or, let's forget about .htaccess for a minute. Maybe, you could do this: create template 'redirection.php', that has one field called 'newUrl', that's used for new url [textfield] <?php $session->redirect($page->newUrl); and create few pages you want to redirect: name: '6-amicizie.html' with the latest code this should be possible and it also gives your visitors and google the right 301 redirect. Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 5, 2011 Author Share Posted February 5, 2011 this is a good idea, thanks... Link to comment Share on other sites More sharing options...
ryan Posted February 6, 2011 Share Posted February 6, 2011 Here's how I setup 301 redirects in my .htaccess files. These redirect directives should go probably above ProcessWire's, but after the "RewriteEngine On" directive. Here's a 301 redirect from one directory to another (/old/ to /new/): RewriteRule ^old/?$ /new/ [R=permanent,L] Here's rewriting /old.html to /new/dir/: RewriteRule ^old.html$ /new/dir/ [R=permanent,L] 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now