Wordpress Multisite url remapping - wordpress

I'm currently using a complex multisite setup. I have the site as the landing page/blog and another site for the main functionality. The subdomain of the main site is set to /dashboard/ so every other page that loads after has the dashboard slug in it. IE www.name.com/dashboard/post-a-project.
Is there was a way to make the website appear as www.name.com/post-a-project while not interfering with the landing page site? This is mostly for aesthetic purposes.

Try and use this in your .htaccess file:
RewriteEngine On
RewriteRule ^dashboard/(.*)$ /$1 [L,R=302]
I've set it to a temporary redirect using R=302. If this works for you then change it to R=301 to make it a permanent redirect.
Make sure you clear your cache before testing this.

Related

Redirecting specific urls to subfolder on same domain

I have moved my phpBB board from dommain.com to domain.com/forum.
I have launched a Wordpress website on domain.com.
As a consequence, all links to topics on my board end up on a 404 page of my Wordpress website on domain.com
I would like to redirect links to topics on my board.
For example:
Redirect: example.com/viewtopic.php?f=17&t=35
To: example.com/forum/viewtopic.php?f=17&t=35
So only /forum should be added.
Is changing the .htaccess file of my WordPress website the best way to do this? And if so, what would be the correct code?
Of are there better ways (faster/better for SEO) that I don't know of.
Is changing the htaccess file of my Wordpress website the best way to do this?
Implementing this in the root .htaccess file is a reasonable way to do this, unless you have access to the main server config. Alternatively, you could perform this redirect in PHP (in WordPress), but that puts the burden on your WordPress site.
For example, at the top of your root .htaccess file, before the existing WordPress directives (ie. before # BEGIN WordPress) try the following:
# Redirect old forum topics to "/forum" subdirectory
RewriteRule ^viewtopic\.php$ /forum/$0 [R=301,L]
Any query string is passed through by default. So, a request for /viewtopic.php?<something> is redirected to /forum/viewtopic.php?<something>.
The $0 backreference contains the URL-path matched by the entire RewriteRule pattern. ie. "viewtopic.php" (this simply saves repetition).
NB: You should test first with a 302 (temporary) redirect to avoid potential caching issues.

301 not working with child pages

I have wordpress site that i am redirecting via entries in the htaccess file. The main page redirects work, but the child pages are not correct. Below is a sample redirect from the file.
Redirect 301 /services/additional-background-screening-services/ https://www.inlinereferencecheck.ca/services.html
The above redirect links to https://www.inlinereferencecheck.ca/services.html/additional-background-screening-services/ on the target site
have I configured something wrong? The top level links work fine
Don't use mod_alias' Redirect to redirect with changing URLs, use mod_rewrite. mod_alias is made for cases where you want to do simple redirects from https://example.com/* to https://example.org/, but keep the local URL structure.
Mod_rewrite allows much more fine tuned control. Change it to something like this:
RewriteEngine On
RewriteRule ^services/additional-background-screening-services/$ https://www.inlinereferencecheck.ca/services.html [R=301,L]
And make sure that you put it before the Block of WP rewrite rules.

Permalink for Homepage

I have a simple wordpress question. Currently I have a site with a static home page, when I visit my site examplesite.com the URL reads what it should which is examplesite.com, would it be possible to give this static home page a permalink so that when I load the site it automatically turns to examplesite.com/customlink. What I am saying is I still want the same home page and the same URL to reach it, I just want a specific permalink to appear. I can edit permalinks for all other pages but since this is my homepage I see no option to do it automatically in wordpress.
Inside settings you can set static pages as default.
For this you'll need .htaccess, e.g.
RewriteEngine On
RewriteBase /
RewriteRule ^$ page-you-want [L,R=301]
So any requests to root will get moved to the permalink you want. You don't need to set your home page to a static page/front page.

Redirect non www to www causes infinite loop

I have tried to redirect a Wordpress website using .htaccess but it causes to form an infinite loop. Now there is no redirection for the blog. Still the domain url with www is automatically redirecting to non www. I have checked whole server and I am sure that there is no redirect in the server. Also tried by changing the site address and Wordpress address from dashboard but still creates infinite loop.
There is nothing redirection in template because I have tried by creating a simple .html test file and still the same.
Note: I don't think code is relevant here because the question is where this www to non www redirection came which I haven't given in my code or in the server
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
update:
I just found it out. Plesk configuration files is really tricky, spreads in many places. I can see that the rewrite rule was added in under conf within the website name. I have removed this and change the site url and now everything works fine. Thank you for your support
You don't need edit htaccess. You can do it more safely by specifying the preferred URL in Settings.
If you have domain.com and want users to be redirected to www.domain.com , then keep www.domain.com in the settings and vice versa. Wordpress will manage the www redirection.
Similarly you can manage path also, if you want users to see example.com/blog instead.

How to internally add /blog/ to the url with .htaccess?

Hi I have wordpress installation in subfolder /blog/, as it has to co-exist with other legacy cms, so now if i wish to access some page of wordpress i need to use links as
www.domain.com/blog/news/ and would like to rather use www.domain.com/news/.
So basically for certain links i need to add this /blog/ somehow internally so wordpress
would handle it normally.
Please note it will be few links so rewrite rules can be literal.
Rewriting URI's for wordpress can always be kind of sketchy because wordpress has its own way to do routing and may not play nicely with other rewriting sometimes, but you can try:
RewriteRule ^/?news/some-page$ /blog/news/some-page [L]
As long as they're before any other wordpress related rules.

Resources