使用htaccess从一页重定向到另一页 [英] Redirect From one page to another page using htaccess
本文介绍了使用htaccess从一页重定向到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网站,上面有不同类别的图像。我曾经手动创建网页,直到我了解动态网页(使用mysql和php)。
I have a website with images in different categories. I used to create webpages manually until i cam to know about dynamical webpages (using mysql and php) .
我当前的网址类似于下面的网址。
My current URL is similar to below URL.
http://www.example.com/category/alone/1.php
我需要的是将我手动创建的所有文件重定向到相应的动态创建的页面。对应于上述URL的我的动态页面如下。
What i needed is to redirect all the files which i manually created to corresponding dynamic created pages. My Dynamic page corresponding to above URL is given below.
http://www.example.com/category/alone/1/
现在我在每个页面上使用301重定向到新的对应页面。这需要花费大量时间。我们可以使用.htaccess吗?
Now i am using 301 redirection on each page to new corresponding page. And it takes large time to do. Can we do this using .htaccess ?
推荐答案
尝试:
Options -Multiviews
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+([^/]+)/([^/]+)/([^/.]+)\.php
RewriteRule ^ /%1/%2/%3/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*?)/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule ^(.*?)/?$ /$1.php [L]
这篇关于使用htaccess从一页重定向到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文