测试重写模块是否开启 How To Test Check If Mod_rewrite Is Enabled
<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><< <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.htmlRewriteEngine OnRewriteRule ^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
?