如何将某些网址重定向到不同的格式。
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
我想将上述网址重定向到以下格式。
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
提前致谢。
答案 0 :(得分:1)
应该像:
RewriteEngine on
RewriteRule ^mydir(.*)/(.*)/([a-z\-]{2,}([a-z\-][\d])[\d])(.*)$ $2/$3$1-$4 [R=301,L]
答案 1 :(得分:0)
您可以使用以下内容:
RewriteEngine On
RewriteRule ^/mydir2/(.*)+$ /mydir1/mydir2/$1
答案 2 :(得分:0)
在你的htacces中试试这个:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase http://mysite.com
RewriteRule ^/(.+)$ /mydir1/mydir2/$1 [L]
</IfModule>
注意:此代码未经过测试。
答案 3 :(得分:0)
试试这个,
# 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]
您可以看到此RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
注意:代码未经过测试
答案 4 :(得分:0)
通过httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放在.htaccess
目录下的DOCUMENT_ROOT
中:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^mydir1/([^/]+)/(.+?)-(\d+\.html)$ /$1/$2-1-$3 [L,R=301,NC]