Jump to content

redirect 301


Frank Vèssia
 Share

Recommended Posts

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

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

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]
  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...