LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   301 redirection (https://www.linuxquestions.org/questions/linux-newbie-8/301-redirection-4175550377/)

nithinbp 08-10-2015 08:51 AM

301 redirection
 
Hi,

I would like to 301 redirect all sub urls of my domain containing 'dot' to my main website URL.

For example:

Say my domain is redirecttestdm.com.

I need to redirect links like :
http://redirecttestdm.com/testing/2935/asp.netserver
http://redirecttestdm.com/testing/29...-in-b.e-b.tech

to: http://redirecttestdm.com

Please help.

bathory 08-10-2015 04:31 PM

You may try this:
Code:

RewriteEngine on

RewriteCond %{REQUEST_URI} \.(.+)
RewriteRule .* http://redirecttestdm.com. [R=301]

Regards

nithinbp 08-19-2015 05:26 AM

Thanks Bathory. It worked.

I have another doubt. Is it possible to do a 301 redirection for all pages which is having a soft 404 error.

ie, the page exists but the content removed.

bathory 08-19-2015 07:06 AM

Quote:

Originally Posted by nithinbp (Post 5407846)
Thanks Bathory. It worked.

I have another doubt. Is it possible to do a 301 redirection for all pages which is having a soft 404 error.

ie, the page exists but the content removed.

If the file in question has a 0 byte size, you can use:
Code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule .* http://redirecttestdm.com [R=301]


nithinbp 08-19-2015 07:28 AM

Thanks :)


All times are GMT -5. The time now is 08:31 AM.