Redirect URL with Apache 2.4 - apache

I have a full working site built with Drupal 8. I already managed to use Apache in order to redirect some pages from an old domain to the new one, but now I have to set up a rule to redirect the same page from two URLs. Basically I would like to redirect from https://example.com/course/name-course=?True to
https://example.com/course/name-course.
I already tried to use the RedirectMatch as
RedirectMatch 301 "/(.*)/(.*)?=True" "https://example.com/$1/$2"
But I can't get where I want.

Related

Redirect “test/oldfile.htm” to “test/new.htm” using htaccess

I am Using XAMPP Server.
I have a folder or project named test in my htdocs.
I want to redirect user to redirect to newfile.htm when user access oldfile.htm direcly using htaccess.
I wrote below code in mine htaccess file but its not working
RewriteEngine on
Redirect 301 /oldfile.htm /newfile.htm
Kindly Guide me.
Redirect directive is part of apache alias module. You don't need to write RewriteEngine on to use Redirect. The reason why your Redirect failed is because you are a relative test path, you need to specify a full/absolute path in Redirect.
Redirect 301 /test/oldfile.html /test/newfile.html
should work. If the problem presists, Try clearing your browser cache and make sure you dont have other conflicting redirects in htaccess.

.htaccess rules to redirect certain pages and the catch all others

I'm redirecting a site from an old platform to another. It's got 300-400 pages and all the pages have different names.
It's learn.example.com (old platform) to courses.example.com (new platform)
So I've put in some 301s at the beginning of the .htaccess file of the most important pages, for example:
Redirect 301 /courses-overview/ http://courses.example.com/courses
But at the end I need a catch-all to redirect any other page not previously specified as a 301 like learn.example.com/whatever to courses.example.com to catch any of the other 300-400 pages that don't exist in the .htaccess file now.
Is that possible?
You can Redirectother pages via the following Redirect :
RedirectMatch ^/.*$ http://example.com/
Put this bellow your existing Redirects otherwise Apache will redirect your whole site.

Apache redirecting in CakePHP: old pages ending with .php to new ones

I have a new CakePHP site, and I wish to redirect some old urls to new ones.
/contact.php to /contact
/news.php to /
/courses.php to /courses
I've tried 301 apache redirect inside the .htaccess (the root one, inside /app and inside /app/webroot, but none worked.
I also wanted to redirect all non www urls to www. I looked this thread but the example didn't worked for me. I'm using CakePHP 2.0.
Can somebody help me?
If your CakePHP is installed into root you should be able to redirect these URLs into correct ones with routes.php. Take a look into redirect routing documentation: http://book.cakephp.org/2.0/en/development/routing.html#redirect-routing
is important that your server have mod_rewrite enabled.
You can then modify the url in app/config/routes.php
Although still not clear to me as you had before contact.php type routes

Apache mod_rewrite help with Wordpress

I administer my wife's site, namelymarly.com. Up until last week, the root page of the blog was namelymarly.com/blog/.
Last week I changed it in the WP settings to be namelymarly.com.
WP created the new htaccess file, and I moved the index.php to the root directory (but left the WP folder where it was in the /blog/ directory), as instructed. Everything is working great except for one very important thing:
When you type 'namelymarly.com/blog/' into a browser now, you get a 404 error.
All other URLs, when they include the '/blog/somethinghere', will redirect properly to '/somethinghere.' It's only when there's nothing after '/blog/' that there's a problem.
I tried adding this rule but it still redirects to the 404 page:
RewriteRule ^/blog/$ /index.php
Any suggestions/help?
install "Redirection" and then add a 301 redirect from namelymarly.com/blog/ to namelymarly.com
Did you follow these diections?: Moving WordPress « WordPress Codex
You don't need the redirection plugin. Wordpress handles redirects if you regenerate permaliks. If you have to, use this in .htaccess before the Wordpress rewrite block:
Redirect 301 /blog http://namelymarly.com
But first, be sure you've reset your permalinks in Dashboard/Settings/Permalinks and make sure that copy the changes to .htaccess yourself and that there is only the most recent - the last - rewrite block in the file (WP has a habit of adding more and more rewrite blocks to .htaccess).
And check the URLs of your other URLs in the post/page editor and see if they contain /blog/

301 redirect in Plone CMS (Zope)

I'm running a website hosted on Apache and Plone (based on Zope). My problem is that i have duplicate content with following urls:
www.site.com
www.site.nl/en
www.site.com/nl
and so on, every page shows the same content.
Google Webmaster Tools also reports sites in the following format to be duplicate:
www.site.nl/news
www.site.nl/news/
Notice the trailing slash.
What's the best way to solve this (make a 301 redirect to the proper url)? Can i do this in the Plone source? Or should i use the canonical tag?
Regards
Best place to solve it is in your apache configuration.
Duplicate sites: choose one and permanently redirect the rest. For me, all www.reinout.vanrees.org traffic is redirected to reinout.vanrees.org.
Trailing slashes: redirect URLs ending in / to their non-slash equivalents.
For (1), use this as an example:
<VirtualHost *>
ServerName www.reinout.vanrees.org
Redirect permanent / http://reinout.vanrees.org/
</VirtualHost>
For (2): you probably have big "virtualhostmonster" rewriterule at the end of your apache config. Copy/paste that line and use ^(.*)/$ instead of ^(.*) in the first one. That effectively strips trailing slashes.