如何屏蔽URL

时间:2013-05-04 16:23:27

标签: php .htaccess url mod-rewrite mask

我不是试图隐藏我的网址。我只需要对我的客户好看。我想掩盖的网址是:mysite.com/group/2。如果那是mysite.com/client那就太好了。因此,每当我的客户端点击他的网址mysite.com/client时,后面的代码都来自此网址mysite.com/group/2 group是一个模块(文件夹/来源),2是主要ID 。我尝试过使用Rewrite mod / Apache(.htaccess),但我没有成功。我怎么能这样做?还有其他方法吗?感谢

这是.htaccess

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

# My Rewrite Rule
RewriteRule ^client$ group/2

# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]

# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]

# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]

# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On

# @todo This may not be effective in some cases
FileETag Size

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css                    application/x-javascript application/javascript
</IfModule>

1 个答案:

答案 0 :(得分:0)

而不是在mysite.com/group/2中找到您的文件,尝试将您的文件放在该目录中的mysite.com/client目录中,将您的代码写入处理代码所在的index.php文件中。这就是我在我的网站上为我的博客做的事情