Where to add 301 redirects in bulk using .htaccess ?

Permalink
I have lots of 301 redirects for my new concrete 5.7.4 website. Right now, I am adding 301 redirects by going to
page setting -> location -> Other URLs that should redirect to this page

I have to do this for every page.
Is it possible to do this at once using .htaccess file ? Where should I place .htaccess file ?

srjahir32
 
mnakalay replied on at Permalink Reply
mnakalay
it is possible. Your htaccess should be at the root of your website where the file index.php is.

Try this tool to get the correct redirect to put in your htaccess file:http://www.rapidtables.com/web/tools/redirect-generator.htm...
srjahir32 replied on at Permalink Reply
srjahir32
Does redirects from pages uses .htaccess method ?
I mean, if I add redirects to pages one by one, will it use .htaccess method ?

Because I am in fear that , lots of .htaccess redirect will slow down my pages.
mnakalay replied on at Permalink Reply
mnakalay
No redirects set on pages are different.
What's in htaccess will trump everything.

You should think about how you do it though as you don't want too many 301 redirects. It's not good practice.

If you have page redirected because of just part of the url that changed for instance, you probably only need one redirect for all of them.

Say you have several page like so:
http://page-url/some-folder/page-name...

And you want all of them redirected to
http://page-url/some-other-folder/page-name...

where the same bit of the url changes for all your pages...

Than, don't set a redirect for each page, set a redirect for any page including the "some-folder" bit to go to "some-other-folder"
srjahir32 replied on at Permalink Reply
srjahir32
I have website in HTML with 3000 pages and have good page rank. Now I am migrating my website to concrete5. I will keep same structure of URL but there won't be .html extension.

And I don't want to loose page rank. That's why I am using 301 redirects from old HTML site to new concrete site.

What should be the best option for that ?
mnakalay replied on at Permalink Best Answer Reply
mnakalay
I am no htaccess expert but you can do this
RedirectMatch 301 (.*)\.html$ http://www.example.com$1/

With that, any file named somefile.html will be redirected tohttp://example.com/somefile/

I suggest you check this page:http://www.webweaver.nu/html-tips/web-redirection.shtml...

Know that htaccess will not work on a Windows server.
srjahir32 replied on at Permalink Reply
srjahir32
I have applied above rule to .htaccess file.
But my site is in subdirectory called "C5"

Website URL :http://www.codersvolt.com/c5

When I try to open a page with HTML, this rule adds one more C5 to URL.
For URL :www.www.codersvolt.com/c5/services.html...
redirects to : www.www.codersvolt.com/c5/c5/services.html...
Instead of :www.www.codersvolt.com/c5/services.html...

Below is my .htaccess code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /c5/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
RedirectMatch 301 (.*)\.html$ http://www.codersvolt.com$1
mnakalay replied on at Permalink Reply
mnakalay
I would say that's due to this line
RewriteBase /c5/

But I'm not sure so you'd have to test
srjahir32 replied on at Permalink Reply
srjahir32
This was added by concrete5 for pretty URL
srjahir32 replied on at Permalink Reply
srjahir32
Hi, I tried the way you suggested. Its works fine on all pages, but its redirecting homepage
http://www.codersvolt.com tohttp://www.codersvolt.com/index/... , so it shows page not found on homepage.

Here is my .htaccess code,
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
RedirectMatch 301 (.*)\.html$ http://www.codersvolt.com$1/


Please help me !
mnakalay replied on at Permalink Reply
mnakalay
you might want to try to put your RedirectMatch 301 before the other concrete5 pretty url stuff
srjahir32 replied on at Permalink Reply
srjahir32
I've solved it By using this code.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
RedirectMatch 301 (.*)\.html$ /$1/