Reputation: 1997
How can i redirect some URLs to different format.
http://mysite.com/mydir1/mydir2/my-article-first-86974.html
http://mysite.com/mydir1/somefolder/my-article-76674.html
http://mysite.com/mydir1/anotherfolder/some-text-35667.html
http://mysite.com/mydir1/mydir6/my-article-another-75445.html
I want to redirect the above URLs to below format.
http://mysite.com/mydir2/my-article-first-1-86974.html
http://mysite.com/somefolder/my-article-1-76674.html
http://mysite.com/anotherfolder/some-text-1-35667.html
http://mysite.com/mydir6/my-article-another-1-75445.html
Thanks in advance.
Upvotes: 1
Views: 103
Reputation: 786241
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^mydir1/([^/]+)/(.+?)-(\d+\.html)$ /$1/$2-1-$3 [L,R=301,NC]
Upvotes: 0
Reputation: 10717
Should be like:
RewriteEngine on
RewriteRule ^mydir(.*)/(.*)/([a-z\-]{2,}([a-z\-][\d])[\d])(.*)$ $2/$3$1-$4 [R=301,L]
Upvotes: 1
Reputation: 2559
try this,
# SEO URL Settings
RewriteEngine On
# If your installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
you can see this RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
NOTE:CODE NOT TESTED
Upvotes: 0
Reputation: 32820
Try this in your htacces :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase http://mysite.com
RewriteRule ^/(.+)$ /mydir1/mydir2/$1 [L]
</IfModule>
Note : this code is not tested.
Upvotes: 0
Reputation: 10469
You can use something along these lines:
RewriteEngine On
RewriteRule ^/mydir2/(.*)+$ /mydir1/mydir2/$1
Upvotes: 0