Concrete 5 Domain change - concrete5

I changed the domain of a concrete 5 website according to this documentation
All I did was adding this code to config/site.php
define('BASE_URL', 'http://www.domain.co');
define('DIR_REL', '');
The domain was changed from the server side & the homepage works fine. But when I clicking a link, say navigate to the about us page, the site generates a really long URL with 20 forward slashes.
ex: http://www.domain.co/////////////////////about/
When I reload the page, another 20 appears
ex: http://www.domain.co/////////////////////////////////////////about/
This happens with any link on the homepage & in Chrome shows a browser error "ERR_TOO_MANY_REDIRECTS".
The htaccess seems normal to me.
# -- concrete5 urls start --
<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>
# -- concrete5 urls end --
Any concrete5 experts who can explain what needs to be done?
Thanks heaps!

Remove extra slashes because each backslash a new redirection.
Removing trailing slash
RewriteRule ^(.*)/$ /$1 [L,R]

Related

Is there a way using htaccess to add a virtual directory in URI?

I have my wordpress installed on www.site.com/blog/ but i would like to add language codes in front of the blog directory (www.site.com/us/blog/, www.site.com/es/blog/ and so on). Is there a way achiving this? I need to keep those virtual directories inside URI so when visiting www.site.com/us/blog i want to show www.site.com/us/blog in the address bar.
This is my .htaccess file from www.site.com/blog/ directory.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
RewriteRule ^(.*)/blog/$ blog/?language=$1
it's been a while since i've written .htaccess, let me know how this works out.
edit: here's a helpful tutorial on how it works :)
https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
This should work for you:
RewriteEngine on
RewriteRule ^[a-z]{2}/(.*)$ /$1 [QSA,L]
It checks for any 2 letter prefix at the start of the URL, followed by anything else, then treats that as a request for the bit after, so /us/blog will be treated as a request for /blog, just as /es/page/123 would be treated as a request for /page/123. So long as a visitor goes to the prefixed URL, the address won't be redirected.
If you want to be more specific about what language prefixes to use, do this instead:
RewriteEngine on
RewriteRule ^(es|fr|us)/(.*)$ /$2 [QSA,L]
Making sure you add the ones you want between the first set of parantheses (and separated by pipes (|) as shown above.

Wordpress blank wp-admin and some pages are not working with www

I have moved an Wordpress from one server to another. The address remained the same, so nothing is changed in the URL structure. The steps followed are as described in Codex page.
However when I try to access the admin page (www.mydomain.com/wp-admin) I get a blank page. Also, the same happens to some pages on my site - but not all of them. Some are working some are not.
In my .htaccess I have the usual:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Under wp-admin folder, .htaccess file is empty.
After a lot of testing, I find out that when I access http://mydomain.com/wp-admin (without www) is loading the login page, but after entering the username and password I get another blank page (it basically redirects to www.mydomain.com).
I believe this is not a .htaccess, but something inside Wordpress. I have the correct URL and HOME setup in wp_config (also because the domain did not changed after moving to a different server).
Strange thing is that some pages are working, some don't. What could be the reason?
I found that the reason for this is a blank space left on wp-config.php file, which made WP crash (not sure why other pages were working though...).

Wordpress Mod Rewrite Same Server

I've been researching this for got to be around 6 hours now (had I known I'd spend this long I would have read the manual from start to finish to learn things in-depth) and out of desperation I'm finally asking.
I have a client with two Wordpress sites.
www.myoldsite.com and www.mynewsite.com.
www.myoldsite.com is hosted on a server I can't access while I have access to www.mynewsite.com.
Because of this restraint I've decided to use a .htaccess file on www.mynewsite.com to handle specific 301 redirects and point the domain www.myoldsite.com to www.mynewsite. Most of the redirects are working without any issues but there are a few that aren't. I know why but I can't figure out how to fix it.
For example:
On the www.myoldsite.com they had the page www.myoldsite.com/about-us.
On the new site the new URL is www.mynewsite.com/about-us/what-we-do.
The htaccess file looks like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mynewsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mynewsite\.com$
RewriteRule /about-us "http\:\/\/mynewsite\.com\/about\-us\/what\-we\-do\/" [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
At the moment this causes the recursive error "too many redirects". If I change the Rewrite Rule to:
RewriteRule ^/about-us$ "http\:\/\/mynewsite\.com\/about\-us\/what\-we\-do\/" [R=301,L]
The URL www.myoldsite.com/about-us returns a 404 /index.php not found. This I can tell is coming from Wordpress.
All I need www.myoldsite.com/about-us to point to www.mynewsite.com/about-us/what-we-do using a redirect. If anyone can assist that would be most helpful.
Thanks.
Your RewriteRule is awfully long. I just successfully did the following with no fuss:
RewriteRule ^about-us(/?)$ https://www.google.com/about/ [R=301,L]
I think the forward-slash at the beginning of about-us in your rule is causing a problem.
Also, I'm not 100% sure whether or not browsers cache these redirects, but I've had some trouble in the past with Firefox and 301 redirects where after a change Firefox's behavior continued as before the change and opening a new browser (Safari) worked. You might check into that.

https and http combined .htaccess (different issue)

OK. Hopefully someone can help me with a suggestion-
I have a WordPress multisite using subfolders
I am using WooCommerce
I have a std Ubuntu 12.04/LAMP server with a GoDaddy Certificate installed
If it turn on SSL, it affects my entire domain (obviously) so my primary site ends up as:
'https://main-sitename.com'
My multisite blogs also come up as:
https://main-sitename.com/blogname-1
https://main-sitename.com/blogname-2
and so on. ALL of my menu links are also https which disables outside links because the urls all get prepended with https. :-/
What I am trying to do is get this:
http://main-sitename.com
http://main-sitename.com/blogname-1
http://main-sitename.com/blogname-2
https://main-sitename.com/shop/ (WooCommerce will force HTTPS on checkout and then un-enforce it when done).
So, Anyone have any ideas on how I can remedy this? On an interesting note, when I had the EXACT same site on Rackspace Cloud Sites everything worked fine. When I moved to a self managed Cloudserver this happened. Is there something I missed?
It sounds like SSLRequireSSL has been set for the entire server. Since you only want to enforce HTTPS on /shop/ directory. Add a .htaccess file in that directory that contains:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This will force anyone connecting to your shop with http:// to be redirected to the same URI, but on https://
EDIT 2
This works for me (with www.myserver.com changed to my real server name). I'm using date and name permalinks in WP. As soon as I go to http://www.myserver.com/shop/ I'm redirected to https. It preserves the URI.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Addition to force redirect to https when they visit the shop!
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (shop/.*$) https://www.myserver.com/$1 [R=301,L]
# Back to WordPress changes
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

.htacess custom redirect rules conflicting with Wordpress redirect rules

I am in the process of moving my current static site to Wordpress, using the same domain name.
Both old and new sites have their content in the root folder and also have identical file names, but on the new (Wordpress) site, I have removed the .php extension that exists on the current site and added a trailing slash, as per Wordpress permalinks.
So I need to redirect all the old pages (for example):
/contact-us.php -> /contact-us/
I have tried the well-documented options such as (and variations on this):
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.php$ /$1 [R=301,L]
But this seems to be conflicting with the Wordpress .htaccess rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
When I try to access www.site.com/contact-us.php, I am getting either an infinite loop OR a redirect to www.site.com/index (no .php, no trailing slash), which Wordpress displays as a 404 page.
I have tried with and without the first set of Rewrite conditions (as I see they are duplicated in the Wordpress rules), and also placed my rule before and after the Wordpress rules. No joy. I've also been Googling for the last few hours but no one seems to have addressed this specific problem. I do usually find what I am looking for by searching, so it's in desperation that I'm actually posting (and which is why it's my first post!)
If anyone can help out, I would be very grateful.
It appears you will run into loops when trying an .htaccess redirect because of the php suffix. Maybe someone else knows a solution.
But try a plugin called Redirection « WordPress Plugins. Out of curiosity, I tried a redirect from contact-us.php to contact-us/ and it worked fine. The plugin redirects via php rather than writing to .htaccess, and that may be the difference.
I use the plugin all the time to mostly log 404's and do a few redirects. It doesn't take too much site overhead.
Be sure and set Options to not do "URL Monitoring," as that will set up automatic redirects to to posts/pages that have their permalinks manually changed. And set your 404 logging to a day or two, because the logs can quickly get big and result in huge database tables.
Try using this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Rewrite /something.php to /something/
RewriteRule (.*)/(.*)\.php$ $1/$2/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This method would rewrite:
/contact-us/test/hello.php -> /contact-us/test/hello/
If you don't want subdirectory rewriting replace line 6 with:
RewriteRule /(.*)\.php$ /$1/ [R=301,L]

Resources