View Full Version : Some RewriteRule Help

04-02-2009, 01:06 AM

So currently I have this as my .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ read.php?link=$1

My goal is to take this page: http://www.mysite.com/hehe

and have it show as: http://www.mysite.com/read.php?link=hehe to the server

My current file doesn't work though. I tried changing

RewriteRule ^(.*)$ read.php?link=$1


RewriteRule ^_(.*)$ read.php?link=$1

This works.

Now though the link needs to be http://www.mysite.com/_hehe (which I don't really want).

Can anyone help me get this working the way I want? (Also so when a user does like /index.php it won't try to send it to the server as read.php?link=index.php)

Thanks for any help!

04-02-2009, 11:21 PM
Took some work, but I finally got it.





Works perfectly now :D

04-03-2009, 01:10 AM
I am not an expert on RewriteRule, but what you have is not a complete solution.

What you did is only to exclude . (dot) so index.php doesn't match anymore, but if someone enters http://www.mysite.com/index and if you have Multiviews enabled he will still get index.php.

Another thing to consider is what happens if you already have an URL with a query string?


You would normally want to get:


Your current rule will drop the query string but that might not be what you wanted.

04-06-2009, 11:37 AM

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum