[英]How to URL redirect/rewrite using the .htaccess file
如何为以下URL编写.htaccess重写程序。 我是htaccess的新手。
http://velloredentists.com/search.php?s=VASAN+DENTAL+CLINIC&c=Bagayam )
至
http://velloredentists.com/search/VASAN+DENTAL+CLINIC/Bagayam
请帮我解决这个问题。
1-首先,您需要检查.htaccess
文件是否在网站的根目录中。
2-如果文件.htaccess
存在,请从您的站点下载该文件,在文件末尾添加以下几行,然后将修改后的文件上传回您的站点。 请复制原始文件.htaccess
。 因此,如果出现任何问题,您可以还原原始文件。
3-如果文件.htaccess
不存在,请创建一个新文件.htaccess
并在其下添加以下行。 然后将其上传到您网站的根目录。 如果出现任何问题,可以将其删除。
.htaccess
添加到.htaccess
:
RewriteEngine On
RewriteRule ^search/([^/]*)/([^/]*)\.html$ /search.php?s=$1&c=$2 [L]
这适用于我的apache服务器:
RewriteEngine On
#Redirect "/search.php?s=foo&c=bar to
#/search/foo/bar
RewriteCond %{THE_REQUEST} /search.php\?s=([^&]+)&c=([^\s]+) [NC]
#Rewrite "/search/foo/bar" to
#"/search.php?s=foo&c=bar"
RewriteRule ^ /search/%1/%2? [NC,R,L]
RewriteRule ^search/([^/]+)/([^/]+)/?$ /search.php?s=$1&c=$2 [QSA,L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.