Articles of .htaccess

.htaccess RewiteRulevariables问题

我想要创build使用.htaccess的URL的redirect http://shows.example.com/showtitle/sitemap.xml 映射到我现有的文件夹结构是什么样的 http://shows.example.com/sitemaps/sitemap_shows_showtitle_3day.xml 两个variables可以不同的子域和显示标题 所以我写了 RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ RewriteCond %{REQUEST_URI} ^/([az]*)/sitemap.xml RewriteRule ^(.*)$ http://%1.example.com/sitemaps/sitemap_%1_$1_3day.xml [L] redirect到 http://superstar.example.com/sitemaps/sitemap_superstar__3day.xml 我是否需要将两个RewriteCond合并为一个来访问这两个variables? 或者我可以从这些variables中获得variables吗?

dynamic变为静态

我的网站是一个电子商务网站。 所有url都是dynamic的,例如“my_domain / a.php”,“my_domain / a.php?id = 1”,“my_domain / b.php”,“my_domain / b.php?id = 3”等。 我需要像“my_domain / a.html”,“my_domain / b.html”,“my_domain / c.html”,“my_domain / d.html”等静态url。 我在.htaccess文件中有点弱。 什么我添加到我的.htaccess文件o实现该结果?

Apache为我的域创build的子域提供500内部服务器错误

我已经创build了一个名为http://admin.stenzsolutions.com的子域名,只是为了testing子域名,我主持了与主域名http://www.stenzsolutions.com相同的内容 现在我遇到了子域的问题…主页加载正常,但如果点击任何链接,它会给我一个500内部服务器错误…主要作品像梦一样的内容,没有问题…这是我遇到的问题的确切描述… Internal Server Error ——————— The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available […]

htaccess重写?

我有一个脚本上传图像,为它创build一个散列,创build3个目录,并将图像存储到 imgs/f3s/v5g/234/536_f3sv5g2344270fd093ee8a9bf8de3de32dad.jpg (“536_”是用户名) 所以即时尝试转身 imgs/f3s/v5g/234/536_f3sv5g2344270fd093ee8a9bf8de3de32dad.jpg 成 user_pics/536/536_f3sv5g2344270fd093ee8a9bf8de3de32dad.jpg 我怎样才能做到这一点? 我想如果有人想要查看照片,他们看到在url中的新目录,而不是有3个子目录。 编辑 所以jon的方法工作,但是我需要添加RewriteRule .* index.php/$1 [PT,L]到我的htaccess。 当我补充说,一切都停止工作怎么来? 这是我目前为止所拥有的 RewriteEngine On RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule。* index.php / $ 1 [PT,L] RewriteRule ^ user_pics /([^ /] +)/ [^ ] + (。{3})(。{3})(。{3})(。*)。(jpe?g | gif | png) imgs / $ 2 / $ 3 / $ 4 / $ 1_ $ 2 […]

如何将一个域指向特定的目录?

可能重复: 为不同的域托pipe多个不同的文件夹 我有两个域指向相同的IP地址。 他们都进入目录/public_html/www/ 。 什么是最好的方式,使其中一个域的主目录/public_html/www/somethingelse/ ?

htaccessredirect/ RedirectMatch与包含特殊/编码字符的URL

目前,我正在为一个最近改变其结构的网站在.htaccess文件中应用各种301redirect。 一切工作正常,除了包含特殊字符的url,对于这些我得到404错误。 例如,以下具有注册商标符号(®)的指令可显示404页: RedirectMatch 301 ^/directory/link-with®-special-character(/)?$ somelink.com RedirectMatch 301 ^/directory/link-with%c2%ae-special-character(/)?$ somelink.com 我也尝试使用Redirect , RewriteRule和周围的双引号的url,似乎没有任何工作。 有谁知道可能发生什么事情或处理这些types的指令的正确方法? 任何帮助是极大的赞赏。

.htaccess贝宝和PayPal沙箱

为了在我的前期网站上进行testing,我想只允许我自己的IP和PayPal Sandbox。 为了生产,我想只允许PayPal到我的IPN监听器。 我可以在.htaccess中限制我的IP,但是包括paypal.com会在SandBox的IPN生成器中生成403。 我知道这可能是PayPal的一个安全问题,但如果可能的话,我还是喜欢它。

RewriteCond多个文件

在htaccess文件中,一个文件bla.php RewriteCond可以写出如此的权利? RewriteCond %{REQUEST_FILENAME} !bla.php 问题:怎样才能为多个文件写入RewriteCond? 例如3个文件: bla.php , some_bla.php , some_other_bla.php ?

URI用假子域和多个variables重写

有人可以请尝试使用mod重写的帮助,所以foo.domain.com被重写为domain.com/p.php?s=foo和foo.domain.com/bar到domain.com/p.php?s=foo&p=bar ? 目前我的.htaccess是: RewriteEngine On # Remove www RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L] # Rewrite subdomain etc. RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC] RewriteRule ^([^/]+)/?$ p.php?s=%1&p=$2 [QSA,L,NC] 但我不知道如何抓住第二个variables(是可选的,并在URI末尾的斜杠后,我试图改变条件结束?/(.*)$ ,但无济于事和我的国防部重写技能肯定是悬而未决的!

反转mod_rewrite规则

我想redirect访问 http://www.domain.com/test.php?sub=subdomain&type=cars 至 http://subdomain.domain.com/cars 我已经有了mod_rewrite规则来做相反的事情: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTP_HOST} !^(www)\. [NC] RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.com [NC] RewriteRule (.*) http://www.%2.com/index.php?route=$1&name=%1 [R=301,L] 我需要对这些规则进行哪些更改以将请求从脚本redirect到子域?