如何替换请求URL中的文字
以下解决方案,仅适用于Apache服务器。 在.htaccess文件中添加以下语句: RewriteCond %{REQUEST_URL} "string1" RewriteRule "(.*)"string1(.*)" "$1string2$2" [N,PT] 例如当客户端发出请求URL:example.c
以下解决方案,仅适用于Apache服务器。 在.htaccess文件中添加以下语句: RewriteCond %{REQUEST_URL} "string1" RewriteRule "(.*)"string1(.*)" "$1string2$2" [N,PT] 例如当客户端发出请求URL:example.c
具体操作办法(仅适用于apache网络服务器): 文件位置:apache->conf->httpd.conf 请在httpd.conf中使用Alias指令: Alias /newurl /www/htdocs/oldurl 如:用户访问新的地址example.com/newurl/id34.html 服务器将提供的内容原地址是example.com/www/htd
很多时候,我们考虑把无效的URL比如:用户拼错的URL、不存在的URL重定向到别的网页,例如网站的首页、404页面等。 在httpd.conf或.htaccess文件中使用ErrorDocument来捕获404 (找不到文件)错误: ErrorDocument 404 /index.html DirectoryIndex index.html /path/to/notfound.h