how to rewrite this simple url?

≯℡__Kan透↙ 提交于 2019-12-13 03:38:18

问题


how can i rewrite

www.mysite.com/someURLhere

into

www.mysite.com/ping.php?url=someURLhere

without mistaking local files, and directories as domains.

so i dont want

www.mysite.com/index.php 
www.mysite.com/admin/

to rewrite to

www.mysite.com/ping.php?url=index.php
www.mysite.com/ping.php?url=admin/

回答1:


<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>

If this is a .htaccess file you dont need %{DOCUMENT_ROOT} in both instances.



来源:https://stackoverflow.com/questions/1616963/how-to-rewrite-this-simple-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!