如何重写这个简单的网址? [英] how to rewrite this simple url?
本文介绍了如何重写这个简单的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何重写
www.mysite.com/someURLhere
进入
www.mysite.com/ping.php?url=someURLhere
不要将本地文件和目录误认为域.
without mistaking local files, and directories as domains.
所以我不想
www.mysite.com/index.php
www.mysite.com/admin/
重写
www.mysite.com/ping.php?url=index.php
www.mysite.com/ping.php?url=admin/
推荐答案
<VirtualHost *:80>
ServerName yoursite.com
DocumentRoot /www/yoursite
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ping.php?url=$1 [L,QSA]
</VirtualHost>
如果这是一个 .htaccess 文件,您在这两种情况下都不需要 %{DOCUMENT_ROOT}
.
If this is a .htaccess file you dont need %{DOCUMENT_ROOT}
in both instances.
这篇关于如何重写这个简单的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文