2013-10-14 156 views
0

我知道有很多关于将所有页面重定向到特定的域/ index.php或html页面的教程。
但我需要将我的所有页面重定向到ServerIP/myDirectory/ProjectName/index.php
,因为我在办公室工作,该办公室共享客户端。所以在我的电脑上,我需要去我的本地服务器上的目录,然后使用服务器的wamp。将所有页面重定向到/index.php文件

例如网址:http://192.168.0.100/myDirectory/ePortal/index.php

我怎么能这样做?我在我的htaccess文件中有这个。

RewriteBase /myDirectory/ePortal/ 
RewriteRule .* index.php 

但是这个htaccess是错误的。出现500内部错误。

+1

你试过: 的RewriteRule^/(。*)的http://192.168.0.100/myDirectory/ePortal/index.php [L,R] 虽然是192.168.0.100从外部无法访问,因为它是本地IP。 – jacouh

+0

它的工作,但有一个文件路径的问题。例如:在其工作的实际域中不起作用。 – Pars

+0

我明白你想要做什么。我写了一个框架,基本上做同样的事情(通过'index.php'路由所有流量),并且它有静态路径。你需要查看root和'public /''.htaccess'文件https://github.com/andyhmltn/Cherry-Framework/ – andy

回答

2

你可以试试这个:

# URLs not to redirect: 
RewriteRule ^/?(captcha|My-Another-Url-Not-To-Redirect)\.php$ - [L] 

# redirect all others: 
RewriteRule ^/.* http://192.168.0.100/myDirectory/ePortal/index.php [L,R] 

# or you may want only to redirect the homepage, then comment line above, put this: 
#RewriteRule ^/index\.php http://192.168.0.100/myDirectory/ePortal/index.php [L,R] 
0
<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$/? index.php?url=$1 [PT,L] 

</IfModule> 

这会检查文件不重定向之前就已存在。这是静态路径仍然工作:)

相关问题