`
天梯梦
  • 浏览: 13612324 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

测试重写模块是否开启 How To Test Check If Mod_rewrite Is Enabled

 
阅读更多

Webune customer benefit from apache's mod_rewrite. Every customer being hosted by our shared services has automatically mod_rewrite enabled. However, if you are still not sure whether you have this free service from Webune, you can confirm if its enable by following this simple guide. In this tutorial, you will be create two files, the first one called rewrite.php and the second one .htaccess - I will be using Windows XP notepad to create my files.

DEMO: You can test how it work in our server, the link to the demo is at the bottom of this post

NOTE: If you prefer, you can download the complete script in the attachment provided on this post by our Webune Support Team. Or you can create the files yourself, if you choose to create the files yourself, continue reading...

We will be creating two files:
- rewrite.php
- .htaccess

IMPORTANT: its important that you do not change the name of the files we are creating on this post. if for example you choose not to call rewrite.php and choose to call this file something else like testing.php for example, it will not work. YOU MUST name the files as specified on this tutorial, otherwise, you will have problems. so follow instructions carefully

1. Open a blank notepad document

2. Copy and paste the following code into the blank notepad

<h2 align=center>
<?php /* mod_rewrite Test Page *//* Copyright 2006 Webune.com */
if($_GET['link']==1){echo '<span style="color:red">You are not using mod_rewrite - Try LINK2</span>';} 
elseif($_GET['link']==2){echo'<span style="color:green">Congratulations!! You are using Apache mod_rewrite</span>';} 
else{echo '<span style="color:blue">Linux Apache mod_rewrte Test Tutorial</span>';} ?>
</h2>

<hr>
<title>How To Test mod_rewrite in Apache Linux Server</title>
<p align="center">
	<a href="http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html">Please Give Us Your Comments</a>
</p>

<p>
	<a href="rewrite.php?link=1" style="color:red"><strong>LINK 1</strong></a> 
	= LINK 1 Does NOT use Mod Rewrite. LINK 1 uses standard URL: 
	<u>rewrite.php?link=1</u>
</p>

<p>
	<a href="link2.html" style="color:green"><strong>LINK 2</strong></a> 
	= LINK 2 - Yes, Uses Apache's Mod Rewrite using this URL:: 
	<u>link2.html</u><br><br><br>
	How this works: both links are for this same page, except they both are different. link one is without the mod_rewrite and link2 is using mod_rewrite. Link1 show the php file, with with mod_rewrite we are mascarading the php file into a html file. you can use whatever type of extension you want, you can change it to .htm or .shtml etc... all you have to do is to make sure you also chang it in the .htaccess file
</p>

<p>NOTE: when you click on LINK2, you should see a message that says: Congratulations!! You are using Apache mod_rewrite</p>

<p>500 ERROR: If you get a 500 Error, this means you made a typo or mistake creating the files OR you are not allowed to use .htaccess</p>

<p>404 ERROR: if you get a 404 error, then this means you do not have Mod_Rewrite on this server.</p>

<p></p>

<p>&lt;&lt; <a href="http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html">Go back to webune forums.</a><br><br>NEED HELP? : <a href="http://www.webune.com/forums/how-to-fix-mod-rewrite-500-internal-server-error-on-htaccess-file-apache-t718.html" title="How To Fix Mod_rewrite 500 Internal Server Error On .htaccess File Apache">How To Fix Mod_rewrite 500 Internal Server Error On .htaccess File Apache</a>
</p>

 

3. Now Save the file as "rewrite.php" - When you 'Save As..' in notepad, be sure to put quotes when you are saving the file, otherwise, notepad will add a .txt extension to the file, like this: rewrite.php.txt - is should only be rewrite.php, thats why you have to include the quotes

4. Now create a file called .htaccess - to make this type of file, open another blank notepad document

5. Copy and paste the following code into the .htaccess file:

# SCRIPT CREATED BY WEBUNE.COM
# THIS WORKS WITH rewrite.php FILE
# READ MORE AT: http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]

 

6. Save as ".htaccess" (if you are using notepad as I am, make sure to put quotes in between .htaccess example: ".htaccess" otherwise, notepad will create a file called .htacces.txt and we don't need the .txt at the end only .htaccess)

7. Now upload these two file into a new directory in your site. for example: test/

8. Open the rewrite.php file with your browser to the location you just uploaded. for example:
http://www.your_website.com/test/rewrite.php

9. you should see two links, LINK1 and LINK2 Click on LINK1 and the same page will display.

10. Now click on LINK2 and the same page will display with the a mod_rewrite message. If it doesnt you either did something wrong. Check your steps. If you checked your steps, refresh your browser, and if refreshing doesnt work, then you dont have mod_rewrite enabled or you dont have permission to run .htaccess files on your website. talk to your web hosting company to make sure they allow apache .htaccess - Some hosting companies do not allow .htaccess because some people take advantage of this feature, so many web hosting companies block their users from using. so check with them

If you get a 500 Error, then you do not have mod_rewrite enabled in your server. Or if mod_rewrite is not working for you and you are a Webune customer, please contact our support team to assist you.

Click here to See demo of mod rewrite file

 

if you still need more help, you can visit this link which also contains pictures/images to help you along if you are a beginner.


http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

 

来源:http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

 

分享到:
评论

相关推荐

    IIS7 windows2008 重写模块ISAPI_Rewrite3.msi

    ISAPI_Rewrite3_0104_x64.msi IIS7 windows2008 重写模块ISAPI_Rewrite3.msi

    MOD_REWRITE

    MOD_REWRITE

    ISAPI_Rewrite2.9版(有注册码)

    它的行为是像Apache的mod_Rewrite ,但专为微软的Internet信息服务( IIS ) 。 ISAPI_Rewrite是一个ISAPI筛选器的书面纯的C / C + +所以速度极快。 ISAPI_Rewrite让您的自由,超出标准网址计划和发展自己的计划。 ...

    php检测apache mod_rewrite模块是否安装的方法

    * @title Check if Apache's mod_rewrite is installed. * * @author Pierre-Henry Soria * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved. * @return boolean */ function isRewriteMod() ...

    ISAPI_Rewrite_full v2.9 完整注册版

    您的服务器是否还在使用Isapi_rewrite简化版(精灵版),是否在使用Isapi_rewrite简化版一段时间发现经常会出现无法显示网页的现象? ISAPI_Rewrite是一个强大的基于正则表达式的URL处理引擎。经过过滤的url更符合...

    ISAPI_Rewrite3完美破解版

    经测试过的ISAPI_Rewrite组件,可正常使用,已正常网站伪静态化及反向代理。

    ISAPI_Rewrite3重写组件

    ISAPI_Rewrite3重写组件,容易配置,功能强大

    ISAPI_Rewrite 3.1 Full版破解版

    ISAPI_Rewrite 3.1 Full版破解版 ISAPI_Rewrite是用来做什么的请大家自己去百度,我这里不作说明。 附件下载 uploadfile/ISAPI_Rewrite3_0067.msi(文件大小:3.42MB 下载次数:368) 这个软件不需要注册码就能用,...

    ISAPI_Rewrite3_full完全版及绿色版

    3、打开安装目录下的httpd.conf文件,在里面输入以下内容并保存,这样就没有使用天数的限制了; RegistrationName= wlqcwin RegistrationCode= 2EAD-35GH-66NN-ZYBA 4、安装好后记得给ISAPI_Rewrite3软件安装目录...

    ISAPI_Rewrite3

    官方原版下载地址:...在根目录的httpd.conf 用文本编辑器打开编辑 RegistrationName= WWWWANG_Panda RegistrationCode= 2EAD-35GH-66NN-ZYBA

    isapi_rewrite 3.1.0.75 完整破解版(测试通过,绝对破解没有失效)

    1、用官方0075版本安装好以后,用ISAPI_Rewrite3_0075_cra文件下的两个文件覆盖安装路径下的原文件。 2、在安装目录下找到 httpd.conf 文件。输入以下内容: RegistrationName= coldstar RegistrationCode= 2EAD-...

    ISAPI_Rewrite3【伪静态】插件

    ISAPI_Rewrite3安装、使用方法(ISAPI_Rewrite3版本是3.1.0.73) 安装: 1、先从官网下一个完全版的ISAPI_Rewrite3(http://www.helicontech.com/download/isapi_rewrite/ISAPI_Rewrite3_0073.msi)并安装; 2、在...

    IIS伪静态组件(支持多站点) ISAPI_Rewrite3.1_full0073和0087双版本完全DLL破解版

    重新上传ISAPI_Rewrite3.1_full完全DLL破解版。ISAPI_Rewrite3.1_0073和ISAPI_Rewrite3.1_0087这两个版本任选。 两个版本自己服务器亲测功能完全,破解完整。破解文件为两个DLL。 一、安装: 1、从官网原版下载...

    ISAPI_Rewrite 3.0 URL重写规则

    ISAPI_Rewrite 3.0 URL重写规则 301重定向 防盗链

    ISAPI_Rewrite3的安装和使用

    ISAPI_Rewrite3的安装和使用

    开启Apache mod_rewrite模块示例代码

    主要介绍了如何开启Apache mod_rewrite模块,需要的朋友可以参考下

    ISAPI_Rewrite3_0087注册码/ISAPI_Rewrite3_0087完美破解下载

    之前使用的ISAPI_Rewrite3_0082.msi访问比较大的时候会引起iis6应用程序池挂起,IIS自动停止,iis自动关闭,iis应用程序池无法开启,现在用ISAPI_Rewrite3_0087.msi能很好的解决这个问题。为大家献上最新ISAPI_...

    ISAPI_Rewrite3_0087完美破解

    安装完官方版本后 把破解文件覆盖安装根目录 在根目录的httpd.conf 用文本编辑器打开编辑 RegistrationName= WWWWANG_Panda RegistrationCode= 2EAD-35GH-66NN-ZYBA

    ISAPI_Rewrite3_0056.msi

    网上介绍部署ISAPI Rewrite的文章也不少,但大体都是对老版本的介绍,或者比较凌乱,我按照自己的做法结合前人的经验整理了一下,供大家参考。菜鸟发帖,难免有疏漏的地方,欢迎大家指教,也欢迎大家去我的博客转转...

Global site tag (gtag.js) - Google Analytics