【问题标题】:How to mask a URL如何屏蔽 URL
【发布时间】:2013-05-04 16:23:27
【问题描述】:

我不会试图隐藏我的网址。我只需要对我的客户表现得很好。我要屏蔽的 URL 是:mysite.com/group/2。如果那是mysite.com/client,那就太好了。所以,每当我的客户点击他的 url mysite.com/client 时,后面的代码将来自这个 url 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>

【问题讨论】:

  • 请添加您的 mod_rewrite 尝试,以便我们告诉您它出了什么问题。
  • Repox,我刚刚添加了我的 .htaccess 内容

标签: php .htaccess url mod-rewrite mask


【解决方案1】:

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

【讨论】:

  • 我想过移动目录,但工作量很大。在我开始重新安排任何事情之前,我需要尝试掩盖它。 Tks
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多