Articles of mod rewrite

阿帕奇 – 国防部重写与虚拟主机的问题

我有一个像这样的虚拟主机设置Apache 2.0: <VirtualHost *:80> ServerName wackystore ServerAlias wackyprojects Alias /media/admin /opt/python/lib/python2.7/site-packages/django/contrib/$ Alias /media /opt/DjangoProjects/wacky/media #mod_wsgi setup WSGIScriptAlias / /opt/DjangoProjects/wacky/django.wsgi </VirtualHost> 我有我们的DNS设置,所以“wackystore”和“wackyprojects”去这个服务器。 我想要发生的是mod重写将wackproroject的url改为wackprojects / tools。 例子: http://wackystore -> no change http://wackystore/something -> no change http://wackyprojects/ -> http://wackyprojects/tools http://wackyprojects -> http://wackyprojects/tools http://wackyprojects/something -> no change

apache – 禁止访问一些静态文件

我很难与.htaccess指令。 我正在尝试Codeigniter框架的URL重写。 在生产服务器上一切正常,但我无法正确设置自己的testing服务器。 testing服务器: url重写很好,PHP文件按预期呈现,但通过HTML(CSS,JS,IMG)包括的所有文件不显示,因为它们不可访问,由于: 403 Forbidden You don't have permission to access /path/to/file/plugins-min.css on this server. 这里是我的.htaccess文件: RewriteEngine On # Do not enable rewriting for files or directories that exist RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # For requests that are not actual files or directories, # Rewrite to index.php/URL RewriteRule ^(.*)$ index.php/$1 [PT,L] […]

htaccess mod_rewrite子目录到子域

我正在使用以下RewriteRule将通配符子域redirect到/ users子目录中的相应文件夹: RewriteCond %{REQUEST_URI} !^/users/ [NC] RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC] RewriteCond %1 !=www [NC] RewriteRule ^(.*)$ /users/%1/$1/? [L] 我想通过301redirect到子域版本来阻止直接访问用户的文件夹,如下所示: www.domain.com/users/username/sub1/sub2/ => username.domain.com/sub1/sub2/ 任何帮助将不胜感激!

文档根目录更改时,重写规则停止工作

我在不同的位置有两个文件夹副本。 它们包含完全相同的.htaccess文件。 这两个.htaccess文件具有相同的权限和所有者。 /home/sites/site/public_html/ /var/www/html/site/ 我有一个VirtualHost的DocumentRoot用来指向/home/sites但是我把它改成了/var/www并且重新启动了Apache。 现在我的htaccess规则不再有效。 例如, /story/id应该重写为/index.php?id=$id 。 如果我在浏览器中访问/index.php?id=$id ,页面会自动加载,但如果我去/story/id ,则会出现404错误。 如果我将DocumentRoot更改回旧的根,链接将再次开始工作。 任何想法可能会导致这一点?

Apacheurl重写加号不能按预期工作

我想重写我的网站URL以下两种模式(注:有很多这样的url,我希望使用一个规则来重写它们都) www.hetaoblog.com/hello www.hetaoblog.com/hello/ 至 **www.hetaoblog.com/myblogs/post/hello.jhtml** 所有其他案例,如http://www.hetaoblog.com/不应该改变; 我试过了 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] RewriteRule ^([^/]+)/$ /myblogs/post/$1.jhtml [L] RewriteRule ^(.*)$ /myblogs/post/$1.jhtml [L] </IfModule> 和 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] RewriteRule ^(.+)/$ /myblogs/post/$1.jhtml [L] RewriteRule ^(.*)$ […]

用mod_rewrite服务404页面

我有一个Drupal网站,其中包含下面的默认mod_rewrite规则 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteCond %{REQUEST_URI} !=/server-status RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 这意味着匹配现有文件或目录的请求将被直接提供,而不是触发index.php脚本。 问题是,对不存在的文件的请求不符合上述规则,并被redirect到index.php引导整个Drupal应用程序,并不必要地加载网站。 为了绕过Drupal丢失的文件,我创build了以下规则: RewriteCond %{REQUEST_URI} (.jpg|.jpeg|.css|.js|.png)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* – [L,R=404] 这工作,但问题是, 404redirect依赖于ErrorDocument 404 /index.php结束了引导Drupal 。 我需要保留ErrorDocument 404 /index.php因为Drupal被用来为dynamic内容提供有用的404页面。 我试图定义几个ErrorDocument 404 (1在我的规则之前,1在Drupal规则之前),但只有最后一个适用。 问:如何在不更改ErrorDocument 404指令的情况下为空的404页面提供不存在的文件请求?

将stream量redirect到https网站

在我们的邮件服务器中,有多个虚拟电子邮件域托pipe。 用户可以使用webmail.example.com(这是第一个Apache虚拟主机)来检查邮件,或者他们可以使用mail.THEIR-DOMAIN.com。 如果put mail.THEIR-DOMAIN.com apache显示webmail.example.com,因为它是第一个虚拟主机,mail.THEIR-DOMAIN.com不存在。 最近我们为webmail.example.com强加了https,并添加了这个mod_rewrite规则: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 但是现在用户没有像以前那样获得默认的网页邮件页面。 我们如何将所有来自URL“mail.ANY-DOMAIN.com”的请求redirect到“ https://webmail.example.com ”? 我试过以下,但它没有工作: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (mail.*) https://webmail.example.com 感谢您的帮助提前。

.htaccess httpsredirect最佳方法

我已经搜遍了所有redirect张贴购买别人,不能find我的问题的答案。 我有一个超过3000页的网站,我们正在谷歌重复问题。 我们希望将父目录中的所有内容都保存为http,除了我们的contact.php和login.php页面。 然后我们有3个文件夹必须被保护。 pipe理员,客户,客户 我已经尝试在每个文件夹的单独的.htaccess文件中使用下面的代码,但是当我尝试尝试find一个冲突的时候,我仍然在尝试为主目录find一个好的解决scheme。 RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} admin RewriteRule ^(.*)$ https://www.website.com/$1 [R,L] 任何帮助将不胜感激。

在Snow Leopard上设置Mod_rewrite问题

可能重复: 一切你想知道Mod_Rewrite规则,但不敢问? 我已经回到了这个年龄段的其他事情旁边。 所以请在下面find我的细节,这些细节我仍然得到以下错误: 500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [email protected] 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 […]

Apache2 mod_rewrite用P标记进食凭证

我有一个内部服务器,需要重写入站请求到另一个内部框,出于愚蠢的原因,这两台机器都启用了基本身份validation。 为了解决auth的两个级别,并且因为这些只是内部服务器,所以我认为我可以这样做: RewriteCond %{REQUEST_URI} /api/service RewriteRule /api/service/(.*) http://uname:[email protected]/$1 [L,P] 我的期望是,uname:这个重写得到应用的时候,pword将会在下一个服务器上进行。 我认为'P'标志导致这种情况不会发生,但是我要求这是一个代理请求,因为从请求发起的浏览器不会响应来自不同URI的响应而不是请求。 谢谢