Rewrite scr of images with htaccess - .htaccess

I have an images with not correct first part of src. For example artweb-it.ru/wp-content/uploads/2018/10/block-02s.png has to be artweb.su/wp-content/uploads/2018/10/block-02s.png so I basically want to rewrite artweb-it.ru to artweb.su with htaccess but I don't know anything about rewriting.
Please, help me figuring this out
Here is htaccess rules file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Related

Rewrite in htaccess not working

I have a page locally that is /shop but I want it to redirect to /shop/designs
I tried to do it with .htaccess but nothing seems to be working.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/shop/.*$ /shop/designs/ [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
Any ideas where I am going wrong?
You were almost there, but in htaccess, you cannot use / at the beginning of the path regex.
Change your rule like so:
RewriteEngine On
RewriteRule ^shop$ shop/designs [R=301,L]

i want 301 redirection to multiple pages

i want to change urls of my website, but there many pages, so i cant change them manually.
so i need to change it from htaccess file.
i want to change the below url
http://demos.beusoft.com/ccjk/resource/arabic-translation-services/
with the
http://demos.beusoft.com/ccjk/arabic-translation-services/
i am using wordpress.
this is whole code ....
# BEGIN WordPress
RewriteEngine On
RewriteRule ^ccjk/resource/([^/]+)/$ demos.beusoft.com/ccjk/$1 [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ccjk/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ccjk/index.php [L]
</IfModule>
# END WordPress
please help, how to rewrite the url from the htaccess file.
Try this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ccjk/
RewriteRule ^resource/([^/]+)/$ http://demos.beusoft.com/ccjk/$1/ [L,R=302]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ccjk/index.php [L]
</IfModule>
# END WordPress

How to ignore subfolders and redirect to the root directory with .htaccess

I'm new in the world of .htaccess and I have a problem. I searched in google how to redirect always to a file, like wordpress do it, and I found this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /demo/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /demo/index.php [L]
</IfModule>
I tested this and it works but I want to ignore the subfolders and redirect like it does when you request a folder which doesn't exist. Does anyone how to ignore all the subfolders, and redirect without changing the URL?
Remove the second RewriteCond which checks if directory doesn't exist !-d
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /demo/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /demo/index.php [L]
</IfModule>

htaccess rewrite rule blog links

I have been using htaccess to remove rewrite certain URLs, however I am looking at something a little more complicated at the moment.
Our website blog (WordPress) used to have links like this:
​/blog​/postname/1387
However after redoing the website our links are now currently just
/postname
Would it be possible to redirect any uses from ​/blog​/postname/1387 and get rid of the blog and number at the end via htaccess so it just contains the postname? At the moment I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^blog/(.*)/.*$ $1/
</IfModule>
Would love to hear any hints or tips, as this is not actually doing any redirecting, what am I doing wrong?
Let's just do a little cleanup:
<IfModule mod_rewrite.c>
#Turn on the RewriteEngine
RewriteEngine On
#Rewrites are all relative to /
RewriteBase /
#Explicit - If the request is for index.php, do nothing.
RewriteRule ^index\.php$ - [L]
#Conditional – Unless the file or directory specifically exists,
#If the request is for the old style blog URI, redirect to new style and stop.
#Otherwise, redirect to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)/.*$ $1/ [R=301,L,QSA]
RewriteRule . /index.php [L]
</IfModule>

rewrite/redirect specific word from url .htaccess

I have couple of urls which is generated by wordpress/php
http://mydomain.com/news-2/newsarticle
http://mydomain.com/products/category-2
http://mydomain.com/products/category/products-2
how can I rewrite/redirect any url with -2 to the one without? The result should be
http://mydomain.com/news/newsarticle
http://mydomain.com/products/category
http://mydomain.com/products/category/products
This is what I have so far
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thanks
Add this to you htaccess :
RewriteRule ^(.*)-2(.*)$ /$1$2 [NC,L,R=301]

Resources