redirect 301 all pages that doesn't exist to a new directory - redirect

i had build another website in the directory http://www.example.com/newwebsite/
Now all the old pages that doesn't exist on the website i want to redirect them to http://www.example.com/newwebsite/
I have a lot of pages in google webmaster with 404 error , that i want to resolve it. I understand that a 301 redirect will resolve my problem.
Can you help me with the htaccess to redirect the pages that doesn't exist any more?
thank you

Try this:
RewriteEngine On
RewriteCond !%{REQUEST_URI} ^/newwebsite/
RewriteRule (.*) /newwebsite/$1 [R=301,L]

Related

301 redirect htaccess and Nginx settings issues and .composer folder

I've had some hit and miss results setting up htaccess to forward on a couple of aged domains I acquired to my main site. I wouldn't describe myself as advanced more an enthusiastic intermediate so a nudge in the right direction would be greatly appreciated. I've checked answers but nothing definitive that I can see that relates to my specific issue and the composer folder. In Apache/Nginx I have in directives (http/https)
RewriteEngine On
ErrorDocument 404 https://my-main-site.com/my-page-or-blog-post/
I have 'Restrict the ability to follow symbolic links' unchecked as I have reference to symlinks in htaccess and so avoids a 500 error. I also have put up a static html page so if anyone hits the old aged domain it's not an automatic redirect they'll see the static HTML page with reference to the old/aged domain. So the 301 is sort of in the background but I'm getting a 302 result. My htaccess looks like this......
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old-site-aged-domain.com$ [NC]
RewriteRule ^(.*)$ https://my-main-site.com/my-page-or-blog-post/ [R=301,L]
However when I go in to AHREFS and look at the backlink data it's showing a 302, however it does confirm http>https is working fine.
http://www.old-site-aged-domain.com/info-page.html
301
https://www.old-site-aged-domain.com/info-page.html
302
https://my-main-site.com/my-page-or-blog-post/
In my site root I also have .composer folder (as well as error_docs, .ssh, httpdocs, logs, .revisium_antivirus_cache), I'm sort of aware what the purpose of this is (PHP) but there are 2 further htaccess files in there, the second smaller htaccess file only has 'deny from all' as content. I wonder if this folder with these 2 htaccess files is presenting a problem/conflict i.e. 3 x htaccess files. The smaller htaccess file is in .composer/cache. The larger htaccess file is in .composer. Should I delete these 2 x htaccess files in .composer folder.
Thanks in advance for any help
James
rewrote htaccess on numerous occasions but without success

Typo3 v10 site configuration with a www-subdomain

I created a site configuration in Typo3 10.4.11 for the entry point www.example.com. When browsing to example.com (without www), I get an error message:
Page Not Found The page did not exist or was inaccessible. Reason: No
site configuration found.
I tried to create a static route, which didnĀ“t work. Any other ideas how to redirect to the original page from www.example.com as well as example.com?
If you're running on Apache, I'd suggest to add a redirect to your .htaccess file:
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Put the snippet near to the line with RewriteEngine On.
If you want to have both domains served by TYPO3, then the EXT: host_variants may be an option.
https://github.com/b13/host_variants

PrestaShop: non-www URLs redirecting to 404 error page

I am experiencing a weird issue on my PrestaShop website.
When I am opening an URL without WWW on it, it redirects to the WWW page, but displays 404 page.
for example, when I am trying to access http://mydomain.com/home/contact-us it takes me to http://www.mydomain.com/home/contact-us?controller=404. It should not add ?controller=404 to the end of the url. Why it's doing this and how to fix this issue?
You need to manually edit the .htaccess file of your Prestashop website. You can redirect all non-www urls to add www using this code.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Place the code on top of your .htaccess file or within the condition block for checking mod_rewrite
you can set your url under "Preferences > SEO & URLs". you have to change the options "Shop domain" and "SSL domain" there you can set with or without "WWW".
This is most probably cased by not-generated .htaccess file. Go to BackOffice -> Preferences -> SEO & URLs and click [Save]. This will regenerate your .htaccess file.

Having troubles in cPanel with a redirect

I have created a subdomain on my website like such www.mysite.com/forum/
when someone goes to that link, I would like them to be redirected to www.forum.mysite.com
I have set a redirect up in cPanel, but it doesnt seem to redirect the folder. I have also tried setting it up under the sub domain and still not working, is there a htaccess code I can add ?
Any help would be awesome!
Thanks in advance!
CPanel will add this to the .htaccess in your site's public_html root folder. Check if cPanel is creating what you mentioned, if not try this:
RewriteEngine on
RewriteRule ^forum/(.*)$ http://www.forum.mysite.com/$1 [L,NC,R=301]

bbPress Forum - rewrite to wwww.mysite prohibits login

I am using bbPress installation without WordPress integration.
The redirect of the RewriteEngine at the forum site works:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^forum.mysite.com$
RewriteRule (.*)$ http://www.forum.mysite.com/$1 [R=301,L]
The problem is the login into ppPress.
bbPress login does not recognize: http://www.forum.mysite/bb-login.php.
It redirects to: http://forum.mysite.com/bb-login.php.
I tried permalink settings none and name based, same issue.
Does anyone uses redirect in bbPress or how can I eliminate "double" content and redirect permanently to www.?
I redirected from www.forum.mysite.com to forum.mysite.com and achieved to eliminate "double" content.